[ZPT] Re: Syntax troubles

Evan Simpson evan@digicool.com
Thu, 3 May 2001 11:13:13 -0500


From: "Tim Moore" <tmoore@tembel.org>
> The problem there is that the string module isn't imported by default
> in a ZPT python expression (as it is in DTML) so it doesn't know where
> to find the "string" part of that "string.split..." expression.
>
> If you're using version 1.2, then I think this should work:
>
> <tr tal:define="doc_src doc/document_src; apa
python:modules['string'].split(doc_src, '@')">

Exactly.  Also, if you wanted to use the string module a lot, you can
put this near the top of the template:

<div tal:define="global string modules/string" />

> The error message is a little confusing, but I believe that's a Python
> internal thing, and not something generated by Zope or ZPT.

Yes, it's due to TALESErrors and TALES expressions representations.  If
you view the page source, you'll see that the "empty" quotes actually
contain something like:

<PythonExpr "string.split(doc_src, '@')">

Cheers,

Evan @ digicool