[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GMG-Devel] [PATCH 20/83] Register indices and orm events for search.
From: |
Alon Levy |
Subject: |
[GMG-Devel] [PATCH 20/83] Register indices and orm events for search. |
Date: |
Tue, 25 Feb 2014 21:58:03 +0200 |
From: Praveen Kumar <address@hidden>
---
mediagoblin/plugins/search/__init__.py | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/mediagoblin/plugins/search/__init__.py
b/mediagoblin/plugins/search/__init__.py
index 8d1e78c..34f5ffc 100644
--- a/mediagoblin/plugins/search/__init__.py
+++ b/mediagoblin/plugins/search/__init__.py
@@ -19,21 +19,36 @@ import logging
from mediagoblin.tools import pluginapi
-from mediagoblin.plugins.search import indices
-
-from sqlalchemy import event
from mediagoblin.db.models import MediaEntry
+from mediagoblin.plugins.search import schemas
+from mediagoblin.plugins.search.base import SearchIndex
+from mediagoblin.plugins.search import registry
+from mediagoblin.plugins.search import listeners
_log = logging.getLogger(__name__)
PLUGIN_DIR = os.path.dirname(__file__)
-def mediaentry_add_listener(mapper, connection, target):
- _log.info("Received request for addding mediaentry")
- _log.info(type(connection))
- _log.info(target.title)
+def register_indices():
+ media_entry_search_index = SearchIndex(
+ model = MediaEntry,
+ schema = schemas.MediaEntryIndexSchema,
+ )
+
+ registry.IndexRegistry.register(media_entry_search_index)
+ _log.info("Registered %(index_name)s index for %(model_name)s"%({
+ 'index_name': media_entry_search_index.__class__.__name__,
+ 'model_name': MediaEntry.__name__}))
+
+def activate_orm_events_listeners():
+ indices = registry.IndexRegistry.indices()
+ for index_obj in indices.itervalues():
+ listener = listeners.ORMEventsListener(index_obj.model)
+ listener.activate_listeners()
+ registry.ListenerRegistry.register(listener)
+
def setup_plugin():
_log.info('Setting up Search...')
@@ -48,7 +63,8 @@ def setup_plugin():
]
pluginapi.register_routes(routes)
- indices.register_indices()
+ register_indices()
+ activate_orm_events_listeners()
#event.listen(MediaEntry, 'after_insert', mediaentry_add_listener)
#event.listen(MediaEntry, 'before_insert', mediaentry_before_add_listener)
#_log.info("Registered listening event")
--
1.8.5.3
- [GMG-Devel] [PATCH 10/83] Correct the class index schema class., (continued)
- [GMG-Devel] [PATCH 10/83] Correct the class index schema class., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 11/83] Add indexer for MediaEntry objects., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 12/83] Add IndexRegistry class to maintain the search indices., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 13/83] Clean up plugins.search.indices, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 14/83] Rename base.py to registry.py and indices.py to base.py., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 15/83] Add index identifier to SearchIndex., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 16/83] Correct the index identifier., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 17/83] Collect all indices in indices.py, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 18/83] Add method to create a document from a model instance, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 19/83] Add event listeners for tracking ORM events for indices., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 20/83] Register indices and orm events for search.,
Alon Levy <=
- [GMG-Devel] [PATCH 21/83] Fix bugs and add search method in SearchIndex, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 23/83] Add ORMEventsListener class to implement the ORM Events, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 22/83] Add ListenerRegistry class to collect all the listeners., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 24/83] Correct indentations in search.__init__, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 25/83] Add search forms., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 26/83] Add view to handle search queries., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 27/83] Add html template for search page., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 28/83] Fix bugs, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 29/83] Add methods to interpret results by the SearchIndex object, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 30/83] fix parameters in search views, Alon Levy, 2014/02/25