--- a/src/pyams_skin/resources.py Thu Jun 02 16:29:59 2016 +0200
+++ b/src/pyams_skin/resources.py Thu Jun 02 16:33:03 2016 +0200
@@ -22,35 +22,25 @@
# import packages
from pyams_skin import myams
-from pyams_utils.adapter import adapter_config
+from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
from zope.interface import Interface
@adapter_config(context=(Interface, IRequest, Interface), provides=IResources)
-class ResourcesAdapter(object):
+class ResourcesAdapter(ContextRequestViewAdapter):
"""Get context resources"""
- def __init__(self, context, request, view):
- self.context = context
- self.request = request
- self.view = view
-
def get_resources(self):
myams.need()
@adapter_config(name='resources', context=(Interface, IRequest, Interface), provides=ITALESExtension)
-class ResourcesTalesExtension(object):
+class ResourcesTalesExtension(ContextRequestViewAdapter):
"""expression:resources TALES extension"""
- def __init__(self, context, request, view):
- self.context = context
- self.request = request
- self.view = view
-
def render(self, context=None):
if context is None:
context = self.context
- resources = self.request.registry.queryMultiAdapter((context, self.request, self.view), IResources)
- if resources is not None:
- return resources.get_resources()
+ for name, adapter in self.request.registry.getAdapters((context, self.request, self.view), IResources):
+ adapter.get_resources()
+ return ''