[Zope] In DTML, no cookie then default. How?
Blandford, Simon [BSS Audio UK]
Simon.Blandford@bss.co.uk
Wed, 20 Jun 2001 14:10:44 +0100
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0F98A.69DD2E80
Content-Type: text/plain;
charset="iso-8859-1"
Hi,
I have worked out how to store cookies and retreive them in DTML to store
preferences on a form.
Question.
If the cookie isn't there yet or gets deleted/rejected etc. How do I insert
a default value into the name space?
What I need is something like...
if <thing> isn't there then <thing>=some default value.
What would solve my problems would be if <dtml-let> didn't need a closing
</dtml-let>.
Background...
This cookie is used to enter a preference value in a form, thus...
<tr>
<th align="left">Batch Size</th>
<td><input type='integer' name='batch_size:int' size=2
value="&dtml.missing-batch_size;" /></td>
</tr>
When the form is entered the cookie is set to the value inserted by the
user, thus...
<dtml-if "REQUEST.has_key('batch_size')">
<dtml-call "RESPONSE.setCookie('batch_size', batch_size, expires='Wed, 19
Feb 2020 14:28:00 GMT')">
</dtml-if>
When the user comes back to the form, the value of batch_size is magically
read from the cookie as a default again.
Problem...
The form is called for the first time so there is no cookie. How do I set
batch_size to a default value?
Regards,
Simon.
------_=_NextPart_001_01C0F98A.69DD2E80
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.00.3315.2870" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001>Hi,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>I have worked out
how to store cookies and retreive them in DTML to store preferences on a
form.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001>Question.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>If the cookie isn't
there yet or gets deleted/rejected etc. How do I insert a default value into the
name space?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>What I need is
something like...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>if <thing>
isn't there then <thing>=some default value.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>What would solve my
problems would be if <dtml-let> didn't need a closing
</dtml-let>.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001>Background...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>This cookie is used
to enter a preference value in a form, thus...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001> <tr><BR> <th
align="left">Batch Size</th><BR> <td><input
type='integer' name='batch_size:int'
size=2<BR> value="&dtml.missing-batch_size;"
/></td><BR> </tr><BR></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>When the form is
entered the cookie is set to the value inserted by the user,
thus...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001><dtml-if
"REQUEST.has_key('batch_size')"><BR> <dtml-call
"RESPONSE.setCookie('batch_size', batch_size, expires='Wed, 19 Feb 2020 14:28:00
GMT')"><BR></dtml-if></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>When the user comes
back to the form, the value of batch_size is magically read from the cookie as a
default again.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001>Problem...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=142445512-20062001>The form is called
for the first time so there is no cookie. How do I set batch_size to a default
value?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001>Regards,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001>Simon.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=142445512-20062001><BR> </DIV></SPAN></FONT></BODY></HTML>
------_=_NextPart_001_01C0F98A.69DD2E80--