Return empty string in TALES expression if required extension can't be found
authorThierry Florac <tflorac@ulthar.net>
Fri, 18 Jan 2019 10:24:20 +0100
changeset 320 8984904dc040
parent 319 0f0e69a1d793
child 321 247c4f2948ef
Return empty string in TALES expression if required extension can't be found
src/pyams_utils/tales.py
--- a/src/pyams_utils/tales.py	Thu Jan 17 14:23:59 2019 +0100
+++ b/src/pyams_utils/tales.py	Fri Jan 18 10:24:20 2019 +0100
@@ -16,15 +16,15 @@
 # import standard library
 import re
 
-# import interfaces
-from pyams_utils.interfaces.tales import ITALESExtension
-
 # import packages
 from chameleon.astutil import Symbol
 from chameleon.codegen import template
 from chameleon.tales import StringExpr
 from zope.contentprovider.tales import addTALNamespaceData
 
+# import interfaces
+from pyams_utils.interfaces.tales import ITALESExtension
+
 
 class ContextExprMixin(object):
     """Mixin-class for expression compilers"""
@@ -97,9 +97,9 @@
     if extension is None:
         extension = registry.queryAdapter(context, ITALESExtension, name=name)
 
-    # provide a useful error message, if the extension was not found.
+    # return an empty string if the extension was not found.
     if extension is None:
-        return None
+        return ''
 
     # Insert the data gotten from the context
     addTALNamespaceData(extension, econtext)