[GMG-Devel] [PATCH 19/83] Add event listeners for tracking ORM events for indices.

Alon Levy alon at pobox.com
Tue Feb 25 14:58:02 EST 2014


From: Praveen Kumar <praveen97uma at gmail.com>

---
 mediagoblin/plugins/search/__init__.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/mediagoblin/plugins/search/__init__.py b/mediagoblin/plugins/search/__init__.py
index f820441..8d1e78c 100644
--- a/mediagoblin/plugins/search/__init__.py
+++ b/mediagoblin/plugins/search/__init__.py
@@ -19,10 +19,21 @@ import logging
 
 from mediagoblin.tools import pluginapi
 
+from mediagoblin.plugins.search import indices
+
+from sqlalchemy import event
+from mediagoblin.db.models import MediaEntry
+
 _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 setup_plugin():
     _log.info('Setting up Search...')
 
@@ -37,6 +48,11 @@ def setup_plugin():
     ]
 
     pluginapi.register_routes(routes)
+    indices.register_indices()
+    #event.listen(MediaEntry, 'after_insert', mediaentry_add_listener)
+    #event.listen(MediaEntry, 'before_insert', mediaentry_before_add_listener)
+    #_log.info("Registered listening event") 
+
 
 hooks = {
     'setup': setup_plugin}
-- 
1.8.5.3



More information about the devel mailing list