-
Notifications
You must be signed in to change notification settings - Fork 5
/
interfaces.py
93 lines (75 loc) · 3.03 KB
/
interfaces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from ckan.plugins.interfaces import Interface
class ISiteSearch(Interface):
"""
Hooks into the search actions to implement custom logic.
These methods will be called before/after the search is performed to allow
users to modify the search parameters or the search results.
For the case of before_* methods, extensions will receive a dictionary with
the query parameters, and should return a modified (or not) version of it.
For the case of after_* methods (except site_search), extensions will
receive the search results, as well as the search parameters, and should
return a modified (or not) object with the same structure::
{'count': '', 'results': '', 'search_facets': ''}
Note that count and facets may need to be adjusted if the extension
changed the results for some reason.
"""
def before_site_search(self, search_params):
"""
Called before the site search is performed.
"""
return search_params
def after_site_search(self, search_results, search_params):
"""
Called after the site search is performed.
This method has a specific search_results structure since it
joins into one dictionary the results of the other searches. The
expected structure is::
{
'datasets': {'count': '', 'results': '', 'search_facets': ''},
'organizations': {'count': '', 'results': '', 'search_facets': ''},
'groups': {'count': '', 'results': '', 'search_facets': ''},
'users': {'count': '', 'results': '', 'search_facets': ''},
'pages': {'count': '', 'results': '', 'search_facets': ''}
}
"""
return search_results
def before_organization_search(self, search_params):
"""
Called before the organization search is performed.
"""
return search_params
def after_organization_search(self, search_results, search_params):
"""
Called after the organization search is performed.
"""
return search_results
def before_group_search(self, search_params):
"""
Called before the group search is performed.
"""
return search_params
def after_group_search(self, search_results, search_params):
"""
Called after the group search is performed.
"""
return search_results
def before_user_search(self, search_params):
"""
Called before the user search is performed.
"""
return search_params
def after_user_search(self, search_results, search_params):
"""
Called after the user search is performed.
"""
return search_results
def before_page_search(self, search_params):
"""
Called before the page search is performed.
"""
return search_params
def after_page_search(self, search_results, search_params):
"""
Called after the page search is performed.
"""
return search_results