Thanks, the external method appears to work fine.  I thought about the
silly Page  Template, but forgot the path: modifier exists!  But the EM
should be far faster, anyway.

Thanks again.

jim

[EMAIL PROTECTED] wrote on 06/21/2006 04:04:31 PM:

> 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  -  Zope@zope.org
> 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 )

_______________________________________________
Zope maillist  -  Zope@zope.org
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 )

Reply via email to