[Zope] Using batch variables in expressions
Phillip J. Eby
pje@telecommunity.com
Tue, 26 Oct 1999 17:34:32 -0500
At 05:14 PM 10/26/99 -0500, Ben Glazer wrote:
>I want to verify that certain fields in a form have been entered. Here's a
>code snippet I've tried to use:
>
><dtml-let required="('first', 'last', 'email')">
> <dtml-in required>
> <dtml-var sequence-item> exists
> </dtml-if>
> </dtml-in>
></dtml-let>
>
>
>Naturally, I get an error when this is executed, since Python interprets
>"sequence-item" in the dtml-if as subtracting item from sequence. I thought
><dtml-var sequence-item> might work, but apparently that sort of thing is
>not allowed in an expression.
>
>Is there a way to access the value of sequence-item in an expression? If
>not, how could I go about verifying that form fields are entered correctly?
Use:
<dtml-if expr="REQUEST.form[_['sequence-item']]">
>As a side note, is there any good reason that sequence-item isn't spelled
>sequence_item? Just curious...
There are some reasons, but "good" is a relative question. One reason is
that it makes it easier for the special mapping object created by the "in"
tag to recognize special variables.
This question is probably becoming a FAQ that should be included in DTML docs.