Evaluation context for untrusted programs.
beginScope()
createErrorInfo(err, position)
endScope()
evaluate(expression)
evaluateBoolean(expr)
evaluateCode(lang, code)
evaluateMacro(expr)
evaluateMacro gets security-proxied macro programs when this is run with the zopeTraverser, and in other untrusted situations. This will cause evaluation to fail in zope.tal.talinterpreter, which knows nothing of security proxies. Therefore, this method removes any proxy from the evaluated expression.
>>> output = [('version', 'xxx'), ('mode', 'html'), ('other', 'things')] >>> def expression(context): ... return ProxyFactory(output) ... >>> zc = ZopeContext(ExpressionEngine, {}) >>> out = zc.evaluateMacro(expression) >>> type(out) <type 'list'>
The method does some trivial checking to make sure we are getting back a macro like we expect: it must be a sequence of sequences, in which the first sequence must start with 'version', and the second must start with 'mode'.
>>> del output[0] >>> zc.evaluateMacro(expression) # doctest: +ELLIPSIS Traceback (most recent call last): ... ValueError: ('unexpected result from macro evaluation.', ...)
>>> del output[:] >>> zc.evaluateMacro(expression) # doctest: +ELLIPSIS Traceback (most recent call last): ... ValueError: ('unexpected result from macro evaluation.', ...)
>>> output = None >>> zc.evaluateMacro(expression) # doctest: +ELLIPSIS Traceback (most recent call last): ... ValueError: ('unexpected result from macro evaluation.', ...)
evaluateStructure(expression)
evaluateText(expr)
evaluateValue(expression)
getDefault()
getValue(name, default=None)
setContext(name, value)
setGlobal(name, value)
setLocal(name, value)
setPosition(position)
setRepeat(name, expr)
setSourceFile(source_file)
translate(msgid, domain=None, mapping=None, default=None)
There are no known subclasses.