changeset 441:7a5557f9355f

merge
author Michael Mayorov <marchael@kb.csu.ru>
date Mon, 15 Aug 2011 18:41:37 +0000
parents 81744c1ebd2e (current diff) 2340dd0ee580 (diff)
children d71800ea7e4c
files MoinMoin/search/revision_converter.py
diffstat 4 files changed, 25 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/maint/index.py	Mon Aug 15 12:14:16 2011 +0000
+++ b/MoinMoin/script/maint/index.py	Mon Aug 15 18:41:37 2011 +0000
@@ -19,7 +19,7 @@
 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
--- a/MoinMoin/search/indexing.py	Mon Aug 15 12:14:16 2011 +0000
+++ b/MoinMoin/search/indexing.py	Mon Aug 15 18:41:37 2011 +0000
@@ -6,12 +6,14 @@
 """
 
 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
 
@@ -19,6 +21,27 @@
 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
--- a/MoinMoin/search/revision_converter.py	Mon Aug 15 12:14:16 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-# 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
-
--- a/MoinMoin/storage/backends/indexing.py	Mon Aug 15 12:14:16 2011 +0000
+++ b/MoinMoin/storage/backends/indexing.py	Mon Aug 15 18:41:37 2011 +0000
@@ -25,7 +25,7 @@
 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