[Zope] Using TAL outside Zope with path expressions

Fred Drake fdrake at gmail.com
Fri Jul 23 17:57:52 EDT 2004


On Thu, 22 Jul 2004 18:26:19 -0300, Rodrigo Dias Arruda Senra
<rodsenra at gpr.com.br> wrote:
>  I'm trying to use TAL (from Zope 2.7.0) outside the
>  Zope context (== standalone program).

Cool!

>  I have cooked a small test case to illustrate
>  where I got stuck. The problems are the following:
> 
>  1) I could not use path expressions inside TAL repeat loops,
>     something like "tal:content='itervar/someattr'" fails.
>     - Apparently DummyEngine does not parses nor handles
>       path expression inside evaluatePathOrVar(expr). It just
>       checks if it belongs to self.locals or sefl.globals
>     How does it work inside Zope ? Does it use a different Engine ?
>     I failed to locate this in the Zope code, any pointers ?

DummyEngine is really only to support testing; it's not intended for
general use.

The engine used for page templates in Zope 2 is in Products.PageTemplates.TALES.

>  2) I could not find how Zope handles 'repeat/itervar/odd' and
>     simmilar constructions upon the repeat var. This also fails
>     when I use TAL outside Zope.

This should work once you switch engines.

>  3) I found some 'z:...' instead of 'tal:...' constructions inside
>     the test cases. They are equivalent ? Is this documented somewhere ?

The namespace prefixes can be anything you want them to be[, XML
style.  The pre-defined namespace prefixes of tal:, metal:, and i18n:
are only provided in HTML mode, but can be augmented using additional
namespace declarations:

  <html xmlns:z="http://xml.zope.org/namespaces/tal">
    The "z:" prefix is now equivalent to "tal:"
  </html>

I urge you to consider using the Zope 3 implementation of page
templates, which has a better separation of the components involved,
and more documentation on how they work together.  It's also the first
to get maintenance attention these days.  You may be particularly
interested in the documentation in the zope.pagetemplate package.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
Zope Corporation


More information about the Zope mailing list