src/pyams_utils/tales.py
changeset 322 a7d712e514a0
parent 320 8984904dc040
child 419 05ff71a02b2d
equal deleted inserted replaced
321:247c4f2948ef 322:a7d712e514a0
    10 # FOR A PARTICULAR PURPOSE.
    10 # FOR A PARTICULAR PURPOSE.
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 
       
    16 # import standard library
       
    17 import re
    15 import re
    18 
    16 
    19 # import packages
       
    20 from chameleon.astutil import Symbol
    17 from chameleon.astutil import Symbol
    21 from chameleon.codegen import template
    18 from chameleon.codegen import template
    22 from chameleon.tales import StringExpr
    19 from chameleon.tales import StringExpr
    23 from zope.contentprovider.tales import addTALNamespaceData
    20 from zope.contentprovider.tales import addTALNamespaceData
    24 
    21 
    25 # import interfaces
       
    26 from pyams_utils.interfaces.tales import ITALESExtension
    22 from pyams_utils.interfaces.tales import ITALESExtension
    27 
    23 
    28 
    24 
    29 class ContextExprMixin(object):
    25 class ContextExprMixin(object):
    30     """Mixin-class for expression compilers"""
    26     """Mixin-class for expression compilers"""
    46 
    42 
    47 def render_extension(econtext, name):
    43 def render_extension(econtext, name):
    48     """TALES extension renderer
    44     """TALES extension renderer
    49 
    45 
    50     See :ref:`tales` for complete description.
    46     See :ref:`tales` for complete description.
       
    47 
       
    48     The requested extension can be called with our without arguments, like in
       
    49     ${structure:tales:my_expression} or ${structure:tales:my_expression(arg1, arg2)}.
       
    50     In the second form, arguments will be passed to the "render" method; arguments can be
       
    51     static (like strings or integers), or can be variables defined into current template
       
    52     context; other Python expressions including computations or functions calls are actually
       
    53     not supported, but dotted syntax is supported to access inner attributes of variables.
    51     """
    54     """
    52 
    55 
    53     def get_value(econtext, arg):
    56     def get_value(econtext, arg):
    54         """Extract argument value from context
    57         """Extract argument value from context
    55 
    58