En/na [EMAIL PROTECTED] ha escrit:
Suppose I have a variable foo that has value "request/name|nothing".
Is it possible from a Python Script to have this evaluated as a TAL
expression?
AFAIK TALES machinery ($ZOPE_HOME/lib/python/Products/PageTemplates)
can't be accessed from restricted code. Maybe ZTUtils,
PythonScript.standard or other module expose it in some way, I don't know.
Alternatives?
* External method:
from Products.PageTemplates.Expressions import getEngine
def evalTAL(talstr, **kw) :
engine = getEngine()
comp = engine.compile(talstr)
return engine.getContext(**kw).evaluate(comp)
then, from a PythonScript do:
result = context.evalTAL("request/name|nothing", here=context,
request=REQUEST)
* Create a PageTemplate named evalTAL with a body like:
<foo tal:replace="python:path(options['param'])"></foo>
then, from a PythonScript do:
result = context.evalTAL(param="request/name|nothing")
result will always be an string. Not a serious alternative, just a
"creative" way.
HTH
_______________________________________________
Zope maillist - [email protected]
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )