Commit 754ff97a authored by Nicolas Gelot's avatar Nicolas Gelot

Create a dedicated handler about plugins hooks in Search class

parent f22fa470
...@@ -200,14 +200,9 @@ def search(request, host): ...@@ -200,14 +200,9 @@ def search(request, host):
name='save_search_' + str(searchData) name='save_search_' + str(searchData)
).start() ).start()
ordered_plugin = request.user_plugins search.search_with_plugins(request, searchData)
plugins.call(ordered_plugin, 'post_search', request, searchData)
for result in searchData.results:
plugins.call(ordered_plugin, 'on_result', request, searchData, result)
return searchData return searchData
class Search(object): class Search(object):
"""Search information container""" """Search information container"""
...@@ -292,6 +287,13 @@ class Search(object): ...@@ -292,6 +287,13 @@ class Search(object):
# return results, suggestions, answers and infoboxes # return results, suggestions, answers and infoboxes
return result_container return result_container
def search_with_plugins(self, request, searchData):
ordered_plugin = request.user_plugins
plugins.call(ordered_plugin, 'post_search', request, searchData)
for result in searchData.results:
plugins.call(ordered_plugin, 'on_result', request, searchData, result)
def get_search_query_from_webapp(self, preferences, form): def get_search_query_from_webapp(self, preferences, form):
# no text for the query ? # no text for the query ?
if not form.get('q'): if not form.get('q'):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment