[Zope] Using batch variables in expressions

Phil Harris phil@wigwamweb.net
Wed, 27 Oct 1999 00:41:36 +0100


You can trap errors using 

<dtml-try .....>
 some stuff
</dtml-except>
 error handling stuff
</dtml-try>

hth

Phil
phil@WigWamWeb.net



> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Ian
> Blenke
> Sent: 26 October 1999 23:55
> To: 'Ben Glazer'; Zope Mailing List
> Cc: Robert Young; Elaine Kant
> Subject: RE: [Zope] Using batch variables in expressions
> 
> 
> 
> 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 )
> 
> _______________________________________________
> 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 )
>