changeset 1262:16bed977b054

Added support for underlay page ignore and prefix filtering in getAllPagesEx, transmit the page list filtered by prefix. Ignore underlay pages in general.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 12 Aug 2006 22:53:48 +0200
parents ae9eb32b6899
children e313c2187271
files MoinMoin/Page.py MoinMoin/action/SyncPages.py MoinMoin/wikisync.py MoinMoin/xmlrpc/__init__.py docs/CHANGES.aschremmer
diffstat 5 files changed, 38 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Sat Aug 12 22:30:49 2006 +0200
+++ b/MoinMoin/Page.py	Sat Aug 12 22:53:48 2006 +0200
@@ -636,7 +636,7 @@
 
         return count
 
-    def getPageList(self, user=None, exists=1, filter=None):
+    def getPageList(self, user=None, exists=1, filter=None, include_underlay=True):
         """ List user readable pages under current page
 
         Currently only request.rootpage is used to list pages, but if we
@@ -693,8 +693,14 @@
                 if filter and not filter(name):
                     continue
 
+                page = Page(request, name)
+
+                # Filter underlay pages
+                if not include_underlay and page.getPageStatus()[0]: # is an underlay page
+                    continue
+
                 # Filter deleted pages
-                if exists and not Page(request, name).exists():
+                if exists and not page.exists():
                     continue
 
                 # Filter out page user may not read.
--- a/MoinMoin/action/SyncPages.py	Sat Aug 12 22:30:49 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Sat Aug 12 22:53:48 2006 +0200
@@ -139,11 +139,11 @@
 
         m_pages = [elem.add_missing_pagename(local, remote) for elem in SyncPage.merge(l_pages, r_pages)]
 
-        print "Got %i local, %i remote pages, %i merged pages" % (len(l_pages), len(r_pages), len(m_pages))
-        
+        print "Got %i local, %i remote pages, %i merged pages" % (len(l_pages), len(r_pages), len(m_pages)) # XXX remove
+
         if params["pageMatch"]:
             m_pages = SyncPage.filter(m_pages, params["pageMatch"].match)
-        print "After filtering: Got %i merges pages" % (len(m_pages), )
+        print "After filtering: Got %i merges pages" % (len(m_pages), ) # XXX remove
 
         on_both_sides = list(SyncPage.iter_local_and_remote(m_pages))
         remote_but_not_local = list(SyncPage.iter_remote_only(m_pages))
--- a/MoinMoin/wikisync.py	Sat Aug 12 22:30:49 2006 +0200
+++ b/MoinMoin/wikisync.py	Sat Aug 12 22:53:48 2006 +0200
@@ -223,7 +223,9 @@
     def get_pages(self, **kwargs):
         options = {"include_revno": True,
                    "include_deleted": True,
-                   "exclude_non_writable": kwargs["exclude_non_writable"]}
+                   "exclude_non_writable": kwargs["exclude_non_writable"],
+                   "include_underlay": False,
+                   "prefix": self.prefix}
         pages = self.connection.getAllPagesEx(options)
         rpages = []
         for name, revno in pages:
@@ -267,12 +269,24 @@
 
     def get_pages(self, **kwargs):
         assert not kwargs
-        return [x for x in [self.createSyncPage(x) for x in self.request.rootpage.getPageList(exists=1)] if x]
+        if self.prefix:
+            page_filter = lambda name,prefix=self.prefix: name.startswith(prefix)
+        else:
+            page_filter = lambda x: True
+        pages = []
+        for x in self.request.rootpage.getPageList(exists=1, include_underlay=False, filter=page_filter):
+            sp = self.createSyncPage(x)
+            if sp:
+                pages.append(sp)
+        return pages
 
     def __repr__(self):
         return "<MoinLocalWiki>"
 
 
+# ------------------ Tags ------------------ 
+
+
 class Tag(object):
     """ This class is used to store information about merging state. """
     
--- a/MoinMoin/xmlrpc/__init__.py	Sat Aug 12 22:30:49 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Sat Aug 12 22:53:48 2006 +0200
@@ -239,11 +239,13 @@
                 include_revno:: set it to True if you want to have lists with [pagename, revno]
                 include_deleted:: set it to True if you want to include deleted pages
                 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
         @rtype: list
         @return: a list of all pages.
         """
         options = {"include_system": True, "include_revno": False, "include_deleted": False,
-                   "exclude_non_writable": False}
+                   "exclude_non_writable": False, "include_underlay": True, "prefix": ""}
         if opts is not None:
             options.update(opts)
 
@@ -255,7 +257,11 @@
         if options["exclude_non_writable"]:
             filter = lambda name, filter=filter: filter(name) and self.request.user.may.write(name)
 
-        pagelist = self.request.rootpage.getPageList(filter=filter, exists=not options["include_deleted"])
+        if options["prefix"]:
+            filter = lambda name, filter=filter, prefix=options["prefix"]: filter(name) and name.startswith(prefix)
+
+        pagelist = self.request.rootpage.getPageList(filter=filter, exists=not options["include_deleted"],
+                                                     include_underlay=options["include_underlay"])
         
         if options['include_revno']:
             return [[self._outstr(x), Page(self.request, x).get_real_rev()] for x in pagelist]
--- a/docs/CHANGES.aschremmer	Sat Aug 12 22:30:49 2006 +0200
+++ b/docs/CHANGES.aschremmer	Sat Aug 12 22:53:48 2006 +0200
@@ -8,6 +8,7 @@
 
   ToDo:
     * Implement all syncronisation cases (all directions, all 3 page sets).
+    * Test with prefixes
     * Reduce round-trip times by caching queries and using MultiCall objects.
     * Attach the status information to the job page.
     * Implement a cross-site authentication system, i.e. mainly an
@@ -96,7 +97,8 @@
          detection from the edit action into the PageEditor class. Enhanced XMLRPC server in Moin to allow
          XMLRPC functions to return Fault instances. Introduced a new diff3 mode that should reduce the
          conflicts. Fixed hard to track down bugs in SyncPages. Store full IWIDs and match by
-         either of both components when searching for tags.
+         either of both components when searching for tags. Ignore underlay pages. Filter the remote page list by
+         the prefix on the remote side.
 
 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