[Zope] Problem with dtml-if sequence-start

Dylan Reinhardt zope@dylanreinhardt.com
03 Aug 2003 21:05:29 -0700


On Sun, 2003-08-03 at 16:14, Borja Prieto wrote:
> Here is my code now:
> 
> <dtml-unless txtCertificado>
>     <dtml-call "RESPONSE.redirect(URL1+'/InicioIC'+'?msg_error=Error: debe
> introducir un número de certificado')">
> </dtml-unless>
> <dtml-in BuscaCertificado>
>      <dtml-if sequence-start>
>          <dtml-call "RESPONSE.redirect(URL1+'/InicioIC'+'?msg_error=Error:
> el certificado '+txtCertificado+' ya existe')">
>      </dtml-if sequence-start>
>      <dtml-call
> "RESPONSE.redirect(URL1+'/IC'+'?txtCertificado='+txtCertificado)">
> </dtml-in>
[snip]
> But when it finds the third case (there is a value for txtCertificado, and
> it is not already in the database) it does nothing. 

That's because there is no possible case where the third dtml-call will
ever be invoked.  If BuscaCertificado is empty (no records found),
there's nothing for dtml-in to loop over.  Control passes to the next
line after </dtml-in>.  Since there is nothing after that tag, your
return is a blank screen... or more accurately, a screen full of
non-rendering whitespace.

Try something like this instead:

<dtml-if txtCertificado>
   <dtml-if BuscaCertificado>
      <dtml-call "RESPONSE.redirect('http://url_1')">
   <dtml-else>
      <dtml-call "RESPONSE.redirect('http://url_2')">
   </dtml-if>
<dtml-else>
   <dtml-call "RESPONSE.redirect('http://error_url')">
</dtml-if>

HTH,

Dylan