[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GMG-Devel] [PATCH 06/83] Remove global constants from the top of indice
From: |
Alon Levy |
Subject: |
[GMG-Devel] [PATCH 06/83] Remove global constants from the top of indices.py |
Date: |
Tue, 25 Feb 2014 21:57:49 +0200 |
From: Praveen Kumar <address@hidden>
---
mediagoblin/plugins/search/indices.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/mediagoblin/plugins/search/indices.py
b/mediagoblin/plugins/search/indices.py
index 6063acb..e6e5c70 100644
--- a/mediagoblin/plugins/search/indices.py
+++ b/mediagoblin/plugins/search/indices.py
@@ -7,9 +7,6 @@ from whoosh import index
config = pluginapi.get_config('mediagoblin.plugins.search')
-SEARCH_INDEX_DIR = config['search_index_dir']
-USE_MULTIPROCESSING = config['use_multiprocessing']
-
class SearchIndex(object):
"""
@@ -20,15 +17,27 @@ class SearchIndex(object):
index.
"""
- def __init__(self, search_index_dir=SEARCH_INDEX_DIR,
- use_multiprocessing=USE_MULTIPROCESSING):
+ def __init__(self, search_index_dir=None, use_multiprocessing=None):
self.schema = None
self.search_index = None
self.search_index_name = self.__class__.__name__.lower()
+
self.search_index_dir = search_index_dir
- self.use_multiprocessing = use_multiprocessing
+ if not self.search_index_dir:
+ self.search_index_dir = config['search_index_dir']
+
+ self.use_multiprocessing = use_multiprocessing
+ if not self.use_multiprocessing:
+ self.use_multiprocessing = config['use_multiprocessing']
def _index_exists(self):
+ """
+ Returns whether a valid index exists in self.search_index_dir.
+
+ If self.search_index is None, it implies that no index has been
+ created yet. In this case, and IndexDoesNotExistsError exception
+ is raised.
+ """
if not self.search_index:
raise IndexDoesNotExistsError(
self.search_index_dir, self.search_index_name)
--
1.8.5.3
- [GMG-Devel] [PATCH 00/83] Search plugin, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 01/83] Register search plugin with mediagoblin.ini, Alon Levy, 2014/02/25
- [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 <=
- [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, 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