[ZPT] How do I...
Evan Simpson
evan@digicool.com
Thu, 17 May 2001 09:25:11 -0400
From: "Tony McDonald" <tony.mcdonald@ncl.ac.uk>
> 1) I want to use the 'odd' path component to switch the background colour
of
> a table row.
In addition to Richard's excellent suggestion, you could do this:
<tr tal:define="odd repeat/item/odd" tal:attributes="bgcolor
python:test(odd, 'red', 'blue')"
> 2) I'd also like to call the above PageTemplate from DTML, substituting
the
> module_code='bgm' above with module_code=modcode, and pass modcode into
the
> PageTemplate.
As you've discovered, PageTemplates don't have the same sort of call
signature as Methods. All keyword arguments are available through the
'options' variable mapping. You can fall back to a request variable like
this:
tal:define="opt (if exists) request/module_code;opt (if exists)
options/module_code"
In the next release, if the current proposals continue to meet with
everyone's approval, you will be able to write:
tal:define="opt options/module_code | request/module_code | nothing"
...and get the argument if it is defined, else the request value if it is
defined, else nothing (None).
Cheers,
Evan @ digicool