[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GMG-Devel] [PATCH 22/83] Add ListenerRegistry class to collect all the
From: |
Alon Levy |
Subject: |
[GMG-Devel] [PATCH 22/83] Add ListenerRegistry class to collect all the listeners. |
Date: |
Tue, 25 Feb 2014 21:58:05 +0200 |
From: Praveen Kumar <address@hidden>
---
mediagoblin/plugins/search/registry.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/mediagoblin/plugins/search/registry.py
b/mediagoblin/plugins/search/registry.py
index 8aacc95..429fe00 100644
--- a/mediagoblin/plugins/search/registry.py
+++ b/mediagoblin/plugins/search/registry.py
@@ -35,3 +35,33 @@ class IndexRegistry(object):
"""
identifier = db_object.__tablename__
return IndexRegistry.get(identifier, not_found)
+
+
+class ListenerRegistry(object):
+ _registry = {}
+
+ @staticmethod
+ def register(listener_obj):
+ """
+ Registers a search.listeners.ORMEventsListener object.
+ """
+ identifier = listener_obj.model.__tablename__
+ ListenerRegistry._registry[identifier] = listener_obj
+
+ @staticmethod
+ def indices():
+ """
+ Return all the listener objects registered.
+ """
+ return ListenerRegistry._registry
+
+ @staticmethod
+ def get(identifier, not_found=None):
+ """
+ Return an ORMEventsListener object identified by `identifier`.
+
+ Returns `not_found` if the listener object was not found.
+ in the regstered list of listeners.
+ """
+ listener = ListenerRegistry._registry.get(identifier, not_found)
+ return listener
--
1.8.5.3
- [GMG-Devel] [PATCH 13/83] Clean up plugins.search.indices, (continued)
- [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, 2014/02/25
- [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 <=
- [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
- [GMG-Devel] [PATCH 31/83] Refactor SearchIndex and add method to update an index., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 32/83] Add event listener for model update, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 33/83] Add listener for model delete event., Alon Levy, 2014/02/25