Commits

marchael committed 7a5557f Merge

merge

  • Participants
  • Parent commits 81744c1, 2340dd0

Comments (0)

Files changed (4)

File MoinMoin/script/maint/index.py

 from MoinMoin.error import FatalError
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError
 from MoinMoin.util.mime import Type
-from MoinMoin.search.revision_converter import backend_to_index
+from MoinMoin.search.indexing import backend_to_index
 from MoinMoin.converter import convert_to_indexable
 
 from MoinMoin import log

File MoinMoin/search/indexing.py

 """
 
 import os
+import datetime
 
 from flask import current_app as app
 
 from whoosh.fields import Schema, TEXT, ID, IDLIST, NUMERIC, DATETIME, KEYWORD, BOOLEAN
 from whoosh.index import open_dir, create_in, EmptyIndexError
 
+from MoinMoin.config import MTIME, NAME
 from MoinMoin.search.analyzers import *
 from MoinMoin.error import FatalError
 
 logging = log.getLogger(__name__)
 
 
+def backend_to_index(backend_rev, rev_no, schema, content, wikiname=u''):
+    """
+    Convert fields from backend format to whoosh schema
+
+    :param backend_rev: MoinMoin backend revision
+    :param rev_no: Revision number
+    :param schema_fields: list with whoosh schema fields
+    :returns: document to put into whoosh index
+    """
+
+    doc = dict([(str(key), value)
+                for key, value in backend_rev.items()
+                if key in schema])
+    doc[MTIME] = datetime.datetime.fromtimestamp(backend_rev[MTIME])
+    doc["name_exact"] = backend_rev[NAME]
+    doc["rev_no"] = rev_no
+    doc["wikiname"] = wikiname
+    doc["content"] = content
+    return doc
+
+
 class WhooshIndex(object):
     """
     Managing whoosh indexes

File MoinMoin/search/revision_converter.py

-# Copyright: 2011 MoinMoin:MichaelMayorov
-# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
-
-"""
-MoinMoin - Backend revision to whoosh revision converter
-"""
-
-
-import datetime
-
-from MoinMoin.config import MTIME, NAME
-
-def backend_to_index(backend_rev, rev_no, schema, content, wikiname=u''):
-    """
-    Convert fields from backend format to whoosh schema
-
-    :param backend_rev: MoinMoin backend revision
-    :param rev_no: Revision number
-    :param schema_fields: list with whoosh schema fields
-    :returns: document to put into whoosh index
-    """
-
-    doc = dict([(str(key), value)
-                for key, value in backend_rev.items()
-                if key in schema])
-    doc[MTIME] = datetime.datetime.fromtimestamp(backend_rev[MTIME])
-    doc["name_exact"] = backend_rev[NAME]
-    doc["rev_no"] = rev_no
-    doc["wikiname"] = wikiname
-    doc["content"] = content
-    return doc
-

File MoinMoin/storage/backends/indexing.py

 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError, \
                                    AccessDeniedError
 from MoinMoin.config import ACL, CONTENTTYPE, UUID, NAME, NAME_OLD, MTIME, TAGS
-from MoinMoin.search.revision_converter import backend_to_index
+from MoinMoin.search.indexing import backend_to_index
 from MoinMoin.converter import convert_to_indexable
 
 from MoinMoin import log