[GMG-Devel] [PATCH 46/83] Add verbose_name and css_id to search results.

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


From: Praveen Kumar <praveen97uma at gmail.com>

---
 mediagoblin/plugins/search/indices.py | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/mediagoblin/plugins/search/indices.py b/mediagoblin/plugins/search/indices.py
index f7b8796..d62548b 100644
--- a/mediagoblin/plugins/search/indices.py
+++ b/mediagoblin/plugins/search/indices.py
@@ -14,18 +14,29 @@ class MediaEntrySearchIndex(SearchIndex):
             model=model, schema=schema, 
             search_index_dir=search_index_dir,
             use_multiprocessing=use_multiprocessing)
+        self.verbose_name = "Media Entries"
+        self.css_id = self.identifier
 
     def _interpret_results(self, results, request_obj=None):
-        _log.info(type(results))
-        all_results = []
+        _log.info("Searched in Media Entries")
+        all_results = {
+            'verbose_name': self.verbose_name,
+            'css_id': self.css_id,
+            'results': [],
+        }
+        search_results = []
         for result in results:
             _log.info(result)
             obj_id = result['id_stored']
             obj = self.model.query.get(obj_id)
-            all_results.append({
+            search_results.append({
                 'slug': obj.slug,
                 'url': obj.url_for_self(request_obj.urlgen),
             })
+        
+        all_results['results'] = search_results
+        _log.info("Found results ")
+        _log.info(all_results)
         return all_results
 
 
@@ -36,19 +47,30 @@ class MediaTagSearchIndex(SearchIndex):
             model=model, schema=schema,
             search_index_dir=search_index_dir,
             use_multiprocessing=use_multiprocessing)
+        
+        self.verbose_name = "Media Tags"
+        self.css_id = self.identifier
 
     def _interpret_results(self, results, request_obj):
+        _log.info("Searched in Media Tags")
         _log.info(results)
-        all_results = []
+        all_results = {
+            'verbose_name': self.verbose_name,
+            'css_id': self.css_id,
+            'results': [],
+        }
+        search_results = []
         for result in results:
             obj_id = result['id_stored']
             obj = self.model.query.get(obj_id)
             media_entry_obj = MediaEntry.query.get(obj.media_entry)
-            all_results.append({
+            search_results.append({
                 'slug': media_entry_obj.slug,
                 'url': media_entry_obj.url_for_self(request_obj.urlgen)
             })
-
+        all_results['results'] = search_results
+        _log.info("Found results")
+        _log.info(all_results)
         return all_results
 
 
-- 
1.8.5.3



More information about the devel mailing list