[Zope] Using batch variables in expressions
Ian Blenke
icblenke@2c2.com
Tue, 26 Oct 1999 18:55:25 -0400
Here's the test form method "foo_test".
<dtml-var standard_html_header>
<form action="foo">
<input name="first" type="hidden">
<input name="last" type="hidden">
<input name="email" type="hidden">
<input type="submit" value="&Submit">
</form>
<dtml-var standard_html_footer>
Here's the method you wrote, named "foo" here, with a few changes:
<dtml-let required="['first', 'last', 'email']">
<dtml-in required>
<dtml-if expr="REQUEST.form[_['sequence-item']]">
<dtml-var sequence-item> exists
</dtml-if>
</dtml-in>
</dtml-let>
This shows that all fields exist.
Perhaps someone else can expound on how you can trap the error that
occurs when the element is missing from REQUEST.form[]
- Ian
-----Original Message-----
From: Ben Glazer [mailto:glazer@scicomp.com]
Sent: Tuesday, October 26, 1999 6:14 PM
To: Zope Mailing List
Cc: Robert Young; Elaine Kant
Subject: [Zope] Using batch variables in expressions
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-if expr="REQUEST.form[sequence-item]">
<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?
As a side note, is there any good reason that sequence-item isn't spelled
sequence_item? Just curious...
Thanks,
Ben
_______________________________________________
Zope maillist - Zope@zope.org
http://www.zope.org/mailman/listinfo/zope
(Related lists - please, no cross posts or HTML encoding!
To receive general Zope announcements, see:
http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org -
http://www.zope.org/mailman/listinfo/zope-dev )