Added check for multi-adapter on IHTMLRenderer interface in 'html' TALES extension
--- a/src/pyams_utils/text.py Mon Jun 19 14:03:54 2017 +0200
+++ b/src/pyams_utils/text.py Mon Jun 19 14:25:40 2017 +0200
@@ -125,7 +125,7 @@
"""*extension:html* TALES expression
If first *context* argument of the renderer is an object for which an :py:class:`IHTMLRenderer`
- can be found, this adapter is used to render the context to HTML; if *context* is a string,
+ adapter can be found, this adapter is used to render the context to HTML; if *context* is a string,
it is converted to HTML using the renderer defined as second parameter; otherwise, context is just
converted to string using the :py:func:`str` function.
"""
@@ -133,7 +133,10 @@
def render(self, context=None, renderer='text'):
if context is None:
context = self.context
- adapter = self.request.registry.queryMultiAdapter((context, self.request, self.view), IHTMLRenderer)
+ registry = self.request.registry
+ adapter = registry.queryMultiAdapter((context, self.request, self.view), IHTMLRenderer)
+ if adapter is None:
+ adapter = registry.queryMultiAdapter((context, self.request), IHTMLRenderer)
if adapter is not None:
return adapter.render()
elif isinstance(context, str):