Example #1
0
try:
    import ExtensionClass
    from cDocumentTemplate import InstanceDict, TemplateDict, \
         render_blocks, safe_callable, join_unicode
except: from pDocumentTemplate import InstanceDict, TemplateDict, \
        render_blocks, safe_callable, join_unicode

functype = type(int_param)
class NotBindable:
    # Used to prevent TemplateDict from trying to bind to functions.
    def __init__(self, f):
        self.__call__ = f

d = TemplateDict.__dict__
for name, f in safe_builtins.items() + utility_builtins.items():
    if type(f) is functype:
        d[name] = NotBindable(f)
    else:
        d[name] = f

if LIMITED_BUILTINS:
    # Replace certain builtins with limited versions.
    from RestrictedPython.Limits import limited_builtins
    for name, f in limited_builtins.items():
        if type(f) is functype:
            d[name] = NotBindable(f)
        else:
            d[name] = f

try:
Example #2
0
    return v or 0


functype = type(int_param)


class NotBindable(object):
    # Used to prevent TemplateDict from trying to bind to functions.
    def __init__(self, f):
        self._func = f

    def __call__(self, *args, **kw):
        return self._func(*args, **kw)


for name, f in list(safe_builtins.items()) + list(utility_builtins.items()):
    if type(f) is functype:
        f = NotBindable(f)
    setattr(TemplateDict, name, f)

if LIMITED_BUILTINS:
    # Replace certain builtins with limited versions.
    from RestrictedPython.Limits import limited_builtins
    for name, f in limited_builtins.items():
        if type(f) is functype:
            f = NotBindable(f)
        setattr(TemplateDict, name, f)


class StringModuleWrapper(object):
    # Wrap the string module so it can deal with TaintedString strings.
Example #3
0
    if v:
        try:
            v = int(v)
        except:
            v = md[v]
            if isinstance(v, str):
                v = int(v)
    return v or 0

functype = type(int_param)
class NotBindable:
    # Used to prevent TemplateDict from trying to bind to functions.
    def __init__(self, f):
        self.__call__ = f

for name, f in safe_builtins.items() + utility_builtins.items():
    if type(f) is functype:
        f = NotBindable(f)
    setattr(TemplateDict, name, f)

if LIMITED_BUILTINS:
    # Replace certain builtins with limited versions.
    from RestrictedPython.Limits import limited_builtins
    for name, f in limited_builtins.items():
        if type(f) is functype:
            f = NotBindable(f)
        setattr(TemplateDict, name, f)

try:
    # Wrap the string module so it can deal with TaintedString strings.
    from ZPublisher.TaintedString import TaintedString