SOLVED: [ZPT] path variable doesn't exist

Casey Duncan casey at zope.com
Wed Jan 21 09:22:26 EST 2004


On Wed, 21 Jan 2004 08:52:19 +0000
"Justin Robertson" <nostrebornitsuj at hotmail.com> wrote:

> What you've written would give you a syntax error I think! I trust you
> meant tal:condition and not tal:define. Anyway, and I think I said
> this before, it gives an Attribute error if cid or tid don't exist.
> 
> This does look somewhat verbose I agree, but essentially I've solved
> my problem, which was to deal with optional arguments in the
> querystring. The way to deal with them is just to put a block like
> this at the top of the page:
> 
> <div tal:define="global arg1 request/arg1 | nothing">
> <div tal:define="global arg2 request/arg2 | nothing">
> <div tal:define="global arg3 request/arg3 | nothing">
> <div tal:define="global arg4 request/arg4 | nothing">
> 
> The you can do what you like with them lower down.

FYI: You can define multiple values in a single tal:define:

  <div tal:define="x request/foo|nothing; 
                   y request/bar|nothing; 
                   z python:x or y or 'baz'">

I would suggest that when you find yourself doing this, however, that
you should seriously think about creating a python script that creates a
datastructure (like a
list or dict) that is already preformatted and setup so that the page
template can just do the presentation.

-Casey



More information about the ZPT mailing list