[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GMG-Devel] [PATCH 12/83] Add IndexRegistry class to maintain the search
From: |
Alon Levy |
Subject: |
[GMG-Devel] [PATCH 12/83] Add IndexRegistry class to maintain the search indices. |
Date: |
Tue, 25 Feb 2014 21:57:55 +0200 |
From: Praveen Kumar <address@hidden>
---
mediagoblin/plugins/search/base.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 mediagoblin/plugins/search/base.py
diff --git a/mediagoblin/plugins/search/base.py
b/mediagoblin/plugins/search/base.py
new file mode 100644
index 0000000..2636fef
--- /dev/null
+++ b/mediagoblin/plugins/search/base.py
@@ -0,0 +1,37 @@
+
+class IndexRegistry(object):
+ _registry = {}
+
+ @staticmethod
+ def register(search_index_obj):
+ """
+ Registers an index object.
+ """
+ identifier = search_index_obj.__tablename__
+ IndexRegistry._registry[identifier] = search_index_obj
+
+ @staticmethod
+ def indices():
+ """
+ Return all the index objects registered.
+ """
+ return IndexRegistry._registry
+
+ @staticmethod
+ def get(identifier, not_found=None):
+ """
+ Return an index identified bu the `identifier`.
+
+ Returns `not_found` if the index object was not found.
+ in the regstered indices.
+ """
+ index = IndexRegistry._registry.get(identifier, not_found)
+ return index
+
+ @staticmethod
+ def get_index_for_object(db_object, not_found=None):
+ """
+ Returns the index object for the given db model object.
+ """
+ identifier = db_object.__tablename__
+ return IndexRegistry.get(identifier, not_found)
--
1.8.5.3
- [GMG-Devel] [PATCH 02/83] Correct indices storage dictionary in config_spec.ini, (continued)
- [GMG-Devel] [PATCH 02/83] Correct indices storage dictionary in config_spec.ini, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 03/83] Refactor exceptions raised by the search plugin, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 04/83] Fix typos in search.models, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 05/83] Rename models.py to indices.py as these will not be stored in db., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 06/83] Remove global constants from the top of indices.py, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 07/83] Fix imports and other bugs in indices.py, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 08/83] Add schemas.py which will store all index schemas., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 09/83] Store also the field names in the SearchIndex object which is also necessary while searching., Alon Levy, 2014/02/25
- [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 <=
- [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