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

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.


* 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.

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to