Garito wrote at 2008-10-8 10:46 +0200:
>How can I import the TALES funcion path on a python script?

You cannot -- while it looks like a normal function, it not really is one.

"path" gets a string but interprets this string with knowledge
about the template's namespace. This shows you that some magic
must be in the background that provides the template namespace
to whatever implements "path".
This magic is unavailable in a "Script Python".


In fact, the "path" handling is prepared in
"Products.PageTemplates.PythonExpr.PythonExpr._bind_used_names"
by the following code:

        for vname in self._f_varnames:
            val = vars.get(vname, _marker)
            if val is _marker:
                has = val = getType(vname)
                if has:
                    val = ExprTypeProxy(vname, val, econtext)
                    names[vname] = val

The last two lines bind "path" to
"ExprTypeProxy('path', val, econtext)".
This is what comes nearest to "the TALES function path".
As you can see, it is not a simple function but one provided with lots of
context information (behind the scenes).
The "econtext" contains the template's namespace.



-- 
Dieter
_______________________________________________
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