--- a/src/pyams_utils/text.py Tue Sep 25 11:28:03 2018 +0200
+++ b/src/pyams_utils/text.py Thu Sep 27 14:37:47 2018 +0200
@@ -12,8 +12,6 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
import html
import docutils.core
@@ -21,9 +19,7 @@
from zope.interface import Interface
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
-# import packages
from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, adapter_config
-# import interfaces
from pyams_utils.interfaces.tales import ITALESExtension
from pyams_utils.interfaces.text import IHTMLRenderer
from pyams_utils.request import check_request
@@ -127,6 +123,9 @@
return renderer.render()
+empty_marker = object()
+
+
@adapter_config(name='html', context=(Interface, Interface, Interface), provides=ITALESExtension)
class HTMLTalesExtension(ContextRequestViewAdapter):
"""*extension:html* TALES expression
@@ -137,9 +136,11 @@
converted to string using the :py:func:`str` function.
"""
- def render(self, context=None, renderer='text'):
- if context is None:
+ def render(self, context=empty_marker, renderer='text'):
+ if context is empty_marker:
context = self.context
+ if not context:
+ return ''
registry = self.request.registry
adapter = registry.queryMultiAdapter((context, self.request, self.view), IHTMLRenderer)
if adapter is None: