changeset 397:65c2c01aa266

Fixing issue with double content indexing, cosmetic changes in debug output
author Michael Mayorov <marchael@kb.csu.ru>
date Fri, 05 Aug 2011 01:12:46 +0000
parents 3c1d17e77d1c
children a9b78e0231c6
files MoinMoin/search/revision_converter.py MoinMoin/storage/backends/indexing.py
diffstat 2 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/revision_converter.py	Wed Aug 03 15:07:33 2011 +0000
+++ b/MoinMoin/search/revision_converter.py	Fri Aug 05 01:12:46 2011 +0000
@@ -12,9 +12,8 @@
 import datetime
 
 from MoinMoin.config import MTIME, NAME
-from MoinMoin.converter import convert_to_indexable
 
-def backend_to_index(backend_rev, rev_no, schema_fields, wikiname=u''):
+def backend_to_index(backend_rev, rev_no, schema_fields, content, wikiname=u''):
     """
     Convert fields from backend format to whoosh schema
 
@@ -31,5 +30,5 @@
     doc["name_exact"] = backend_rev[NAME]
     doc["rev_no"] = rev_no
     doc["wikiname"] = wikiname
-    doc["content"] = convert_to_indexable(backend_rev)
+    doc["content"] = content
     return doc
--- a/MoinMoin/storage/backends/indexing.py	Wed Aug 03 15:07:33 2011 +0000
+++ b/MoinMoin/storage/backends/indexing.py	Fri Aug 05 01:12:46 2011 +0000
@@ -30,6 +30,7 @@
                                    AccessDeniedError
 from MoinMoin.config import ACL, CONTENTTYPE, UUID, NAME, NAME_OLD, MTIME, TAGS
 from MoinMoin.search.revision_converter import backend_to_index
+from MoinMoin.converter import convert_to_indexable
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
@@ -388,28 +389,29 @@
         self.cache_in_item(item_id, rev_id, metas)
         return rev_id
 
-    def add_rev_whoosh(self, uuid, revno, metas):
+    def add_rev_whoosh(self, uuid, revno, rev):
         with self.index_object.all_revisions_index.searcher() as all_revs_searcher:
-            all_found_document = all_revs_searcher.document(uuid=metas[UUID],
+            all_found_document = all_revs_searcher.document(uuid=rev[UUID],
                                                             rev_no=revno,
                                                             wikiname=self.wikiname
                                                            )
         with self.index_object.latest_revisions_index.searcher() as latest_revs_searcher:
-            latest_found_document = latest_revs_searcher.document(uuid=metas[UUID],
+            latest_found_document = latest_revs_searcher.document(uuid=rev[UUID],
                                                                   wikiname=self.wikiname
                                                                  )
-        logging.debug("To add: uuid %s revno %s" % (metas[UUID], revno))
+        logging.debug("Processing: name %s revno %s" % (rev[NAME], revno))
+        rev_content = convert_to_indexable(rev)
         if not all_found_document:
             field_names = self.index_object.all_revisions_index.schema.names()
             with AsyncWriter(self.index_object.all_revisions_index) as async_writer:
-                converted_rev = backend_to_index(metas, revno, field_names, self.wikiname)
-                logging.debug("ALL: add %s %s", converted_rev[UUID], converted_rev["rev_no"])
+                converted_rev = backend_to_index(rev, revno, field_names, rev_content, self.wikiname)
+                logging.debug("All revisions: adding %s %s", converted_rev[NAME], converted_rev["rev_no"])
                 async_writer.add_document(**converted_rev)
         if not latest_found_document or int(revno) > latest_found_document["rev_no"]:
             field_names = self.index_object.latest_revisions_index.schema.names()
             with AsyncWriter(self.index_object.latest_revisions_index) as async_writer:
-                converted_rev = backend_to_index(metas, revno, field_names, self.wikiname)
-                logging.debug("LATEST: Updating %s %s from last", converted_rev[UUID], converted_rev["rev_no"])
+                converted_rev = backend_to_index(rev, revno, field_names, rev_content, self.wikiname)
+                logging.debug("Latest revisions: updating %s %s", converted_rev[NAME], converted_rev["rev_no"])
                 async_writer.update_document(**converted_rev)
 
     def remove_rev(self, uuid, revno):