changeset 1480:c222d149e93f

renaming and deleting pages works for all revisions
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Thu, 24 Aug 2006 15:50:35 +0200
parents b1562b232683
children d92f2261387e
files MoinMoin/PageEditor.py MoinMoin/search/Xapian.py MoinMoin/search/builtin.py
diffstat 3 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Thu Aug 24 15:33:44 2006 +0200
+++ b/MoinMoin/PageEditor.py	Thu Aug 24 15:50:35 2006 +0200
@@ -494,7 +494,7 @@
                 from MoinMoin.search.Xapian import Index
                 index = Index(self.request)
                 if index.exists():
-                    index.remove_item(self.page_name)
+                    index.remove_item(self.page_name, now=0)
                     index.update_page(newpagename)
 
             return True, None
--- a/MoinMoin/search/Xapian.py	Thu Aug 24 15:33:44 2006 +0200
+++ b/MoinMoin/search/Xapian.py	Thu Aug 24 15:50:35 2006 +0200
@@ -267,7 +267,12 @@
         pages = self.update_queue.pages()[:amount]
         for name in pages:
             p = Page(request, name)
-            self._index_page(writer, p, mode='update')
+            if request.cfg.xapian_index_history:
+                for rev in p.getRevList():
+                    self._index_page(writer, Page(request, name, rev=rev),
+                            mode='update')
+            else:
+                self._index_page(writer, p, mode='update')
             self.update_queue.remove([name])
 
         # do page/attachment removals
@@ -618,6 +623,8 @@
                         self._index_page(writer,
                                 Page(request, pagename, rev=rev),
                                 mode)
+                else:
+                    self._index_page(writer, p, mode)
             if files:
                 request.log("indexing all files...")
                 for fname in files:
--- a/MoinMoin/search/builtin.py	Thu Aug 24 15:33:44 2006 +0200
+++ b/MoinMoin/search/builtin.py	Thu Aug 24 15:50:35 2006 +0200
@@ -197,22 +197,26 @@
         #    self.read_lock.release()
         return hits
 
-    def update_page(self, pagename):
+    def update_page(self, pagename, now=1):
         """ Update a single page in the index
 
         @param pagename: the name of the page to update
+        @keyword now: do all updates now (default: 1)
         """
         self.update_queue.append(pagename)
-        self._do_queued_updates_InNewThread()
+        if now:
+           self._do_queued_updates_InNewThread()
 
-    def remove_item(self, pagename, attachment=None):
+    def remove_item(self, pagename, attachment=None, now=1):
         """ Removes a page and all its revisions or a single attachment
 
         @param pagename: name of the page to be removed
-        @param attachment: optional, only remove this attachment of the page
+        @keyword attachment: optional, only remove this attachment of the page
+        @keyword now: do all updates now (default: 1)
         """
         self.remove_queue.append('%s//%s' % (pagename, attachment or ''))
-        self._do_queued_updates_InNewThread()
+        if now:
+            self._do_queued_updates_InNewThread()
 
     def indexPages(self, files=None, mode='update'):
         """ Index all pages (and files, if given)