changeset 1315:ed3baf538cd5

Added infrastructure support for deleted pages in the sync framework.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Thu, 17 Aug 2006 19:53:28 +0200
parents 62b8e7e8d5a5
children c4f6af5ee295
files MoinMoin/wikisync.py MoinMoin/xmlrpc/__init__.py docs/CHANGES.aschremmer
diffstat 3 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wikisync.py	Thu Aug 17 19:11:38 2006 +0200
+++ b/MoinMoin/wikisync.py	Thu Aug 17 19:53:28 2006 +0200
@@ -44,7 +44,8 @@
 
 class SyncPage(object):
     """ This class represents a page in one or two wiki(s). """
-    def __init__(self, name, local_rev=None, remote_rev=None, local_name=None, remote_name=None):
+    def __init__(self, name, local_rev=None, remote_rev=None, local_name=None, remote_name=None,
+                 local_deleted=False, remote_deleted=False):
         """ Creates a SyncPage instance.
             @param name: The canonical name of the page, without prefixes.
             @param local_rev: The revision of the page in the local wiki.
@@ -59,6 +60,8 @@
         self.remote_name = remote_name
         assert local_rev or remote_rev
         assert local_name or remote_name
+        self.local_deleted = local_deleted
+        self.remote_deleted = remote_deleted
         self.local_mime_type = MIMETYPE_MOIN   # XXX no usable storage API yet
         self.remote_mime_type = MIMETYPE_MOIN
 
@@ -110,6 +113,7 @@
             if sp in d:
                 d[sp].remote_rev = sp.remote_rev
                 d[sp].remote_name = sp.remote_name
+                d[sp].remote_deleted = sp.remote_deleted
                 # XXX merge mime type here
             else:
                 d[sp] = sp
@@ -240,14 +244,15 @@
                    "exclude_non_writable": kwargs["exclude_non_writable"],
                    "include_underlay": False,
                    "prefix": self.prefix,
-                   "pagelist": self.pagelist}
+                   "pagelist": self.pagelist,
+                   "mark_deleted": True}
         pages = self.connection.getAllPagesEx(options)
         rpages = []
         for name, revno in pages:
             normalised_name = normalise_pagename(name, self.prefix)
             if normalised_name is None:
                 continue
-            rpages.append(SyncPage(normalised_name, remote_rev=revno, remote_name=name))
+            rpages.append(SyncPage(normalised_name, remote_rev=abs(revno), remote_name=name, remote_deleted=revno < 0))
         return rpages
 
     def __repr__(self):
@@ -274,7 +279,8 @@
             return None
         if normalised_name is None:
             return None
-        return SyncPage(normalised_name, local_rev=Page(self.request, page_name).get_real_rev(), local_name=page_name)
+        page = Page(self.request, page_name)
+        return SyncPage(normalised_name, local_rev=page.get_real_rev(), local_name=page_name, local_deleted=not page.exists())
 
     # Public methods:
 
@@ -298,7 +304,7 @@
         else:
             page_filter = lambda x: True
         pages = []
-        for x in self.request.rootpage.getPageList(exists=1, include_underlay=False, filter=page_filter):
+        for x in self.request.rootpage.getPageList(exists=False, include_underlay=False, filter=page_filter):
             sp = self.createSyncPage(x)
             if sp:
                 pages.append(sp)
--- a/MoinMoin/xmlrpc/__init__.py	Thu Aug 17 19:11:38 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Thu Aug 17 19:53:28 2006 +0200
@@ -241,13 +241,15 @@
                 exclude_non_writable:: do not include pages that the current user may not write to
                 include_underlay:: return underlay pagenames as well
                 prefix:: the page name must begin with this prefix to be included
+                mark_deleted:: returns the revision number -rev_no if the page was deleted.
+                    Makes only sense if you enable include_revno and include_deleted.
         @rtype: list
         @return: a list of all pages.
         """
         from MoinMoin.wikisync import normalise_pagename
         options = {"include_system": True, "include_revno": False, "include_deleted": False,
                    "exclude_non_writable": False, "include_underlay": True, "prefix": "",
-                   "pagelist": None}
+                   "pagelist": None, "mark_deleted": False}
         if opts is not None:
             options.update(opts)
 
@@ -271,10 +273,17 @@
                 return n_name in pagelist
 
         pagelist = self.request.rootpage.getPageList(filter=p_filter, exists=not options["include_deleted"],
-                                                     include_underlay=options["include_underlay"])
+                                                     include_underlay=options["include_underlay"],
+                                                     return_objects=options["include_revno"])
         
         if options['include_revno']:
-            return [[self._outstr(x), Page(self.request, x).get_real_rev()] for x in pagelist]
+            pages = []
+            for x in pagelist:
+                revno = x.get_real_rev()
+                if options["mark_deleted"] and not x.exists():
+                    revno = -revno
+                pages.append([self._outstr(x.page_name), revno])
+            return pages
         else:
             return [self._outstr(x) for x in pagelist]
 
--- a/docs/CHANGES.aschremmer	Thu Aug 17 19:11:38 2006 +0200
+++ b/docs/CHANGES.aschremmer	Thu Aug 17 19:53:28 2006 +0200
@@ -112,6 +112,7 @@
 Week 33: Started designing the solutions for the other sync cases. Store and transmit the
          normalised name. Implemented preliminary mime type support, only transmission of the mime type
          and the new storage API is missing. Changed getDiff interface. Detect renamed pages (and choke :).
+         Added infrastructure support for detecting deleted pages (not used in the merging logic yet).
 
 2006-07-18: the requested daily entry is missing here, see http://moinmoin.wikiwikiweb.de/GoogleSoc2006/BetterProgress
 2006-07-19: the requested daily entry is missing here, see http://moinmoin.wikiwikiweb.de/GoogleSoc2006/BetterProgress
@@ -144,9 +145,3 @@
 2006-08-15: entry missing
 2006-08-16: entry missing
 2006-08-17: entry missing
-
-Time plan
-=========
-In July and August, most parts of the implementation will be finished
-from 07-10 to 07-14 and from 08-03 to 08-19. Between those time spans, there
-are exams.