--- a/src/pyams_thesaurus/thesaurus.py Fri Mar 22 15:23:35 2019 +0100
+++ b/src/pyams_thesaurus/thesaurus.py Fri Mar 22 17:40:32 2019 +0100
@@ -369,11 +369,16 @@
def __init__(self, context=None):
terms = []
if context is not None:
- thesaurus = get_parent(context, IThesaurus)
- if thesaurus is None:
- context_manager = IThesaurusContextManager(context, None)
- if (context_manager is not None) and context_manager.thesaurus_name:
- thesaurus = query_utility(IThesaurus, name=context_manager.thesaurus_name)
+ request = check_request()
+ thesaurus_name = request.headers.get('X-Thesaurus-Name')
+ if thesaurus_name is not None:
+ thesaurus = query_utility(IThesaurus, name=thesaurus_name)
+ else:
+ thesaurus = get_parent(context, IThesaurus)
+ if thesaurus is None:
+ context_manager = IThesaurusContextManager(context, None)
+ if (context_manager is not None) and context_manager.thesaurus_name:
+ thesaurus = query_utility(IThesaurus, name=context_manager.thesaurus_name)
if thesaurus is not None:
extracts = IThesaurusExtracts(thesaurus)
terms = [SimpleTerm(extract.__name__, title=extract.name) for extract in extracts.values()]