--- a/src/pyams_skin/container.py Wed May 23 15:18:07 2018 +0200
+++ b/src/pyams_skin/container.py Wed May 23 15:18:46 2018 +0200
@@ -97,7 +97,7 @@
return {'status': 'success'}
-def switch_element_visibility(request, interface):
+def switch_element_visibility(request, interface, adapter_name=''):
"""Set container element visibility
:param request: original browser request; request should contain a parameter called
@@ -107,9 +107,13 @@
:param interface: container interface to which request's context should be adapted
:return: a JSON object containing a boolean "visible" property defining new element visibility.
"""
- container = interface(request.context, None)
- if container is None:
- raise NotFound()
+ context = request.context
+ if interface.providedBy(context):
+ container = context
+ else:
+ container = request.registry.queryAdapter(context, interface, name=adapter_name)
+ if container is None:
+ raise NotFound()
object_name = request.params.get('object_name')
if not object_name:
raise NotFound()