# HG changeset patch # User Thierry Florac # Date 1553272832 -3600 # Node ID 91b51d5e32e762c65d422b4160e8a429888f05a3 # Parent e7e4b4146a918ecf36c12cd623259d6690d534c9 Use request header to store new thesaurus name diff -r e7e4b4146a91 -r 91b51d5e32e7 src/pyams_thesaurus/thesaurus.py --- 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()]