Problem with dtml-if sequence-start
I have a problem with the following code, wich is a DTML methos that processes a form: <dtml-with REQUEST> (First, I check if the user has completed the txtCertificado field) <dtml-unless txtCertificado> <dtml-return "RESPONSE.redirect(URL1+'/InicioIC'+'?msg_error=Error: debe introducir un número de certificado')"> </dtml-unless> (Then, I lookup in a MySQL table with the method BuscaCertificado if a record with the value txtCertificado does already exists) <dtml-in BuscaCertificado> (if it is found, return with an error message) <dtml-if sequence-start> <dtml-return "RESPONSE.redirect(URL1+'/InicioIC'+'?msg_error=Error: el certificado '+txtCertificado+' ya existe')"> </dtml-if sequence-start> (and if not, go to IC page. This is the part that does not work) <dtml-return "RESPONSE.redirect(URL1+'/IC'+'?msg_error='+txtCertificado)"> </dtml-in> </dtml-with> The problem is that the program, though evaluates right the cases for nonexistent parameter or parameter already in the DB, it does not even reach the line: <dtml-return "RESPONSE.redirect(URL1+'/IC'+'?msg_error='+txtCertificado)"> Instead, it shows a blank page, with no code. There is no problem with this code, because I have tried changing it to show a simple message, and it doesn't work, too. Please, ¿could anyone tell me what I am doing wrong? Thanks in advance Borja Prieto Ursúa Alanta
On Fri, 2003-08-01 at 05:22, Borja Prieto wrote:
I have a problem with the following code, wich is a DTML methos that processes a form:
<dtml-with REQUEST>
At best, this does nothing of any value.
(First, I check if the user has completed the txtCertificado field) <dtml-unless txtCertificado> <dtml-return "RESPONSE.redirect(URL1+'/InicioIC'+'?msg_error=Error: debe introducir un número de certificado')">
There is no dtml-return. You want dtml-call. You can read more about DTML here: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/DTML.stx HTH, Dylan
On Fri, 2003-08-01 at 08:47, Dylan Reinhardt wrote:
There is no dtml-return. You want dtml-call.
Grr... sorry. Of course there *is* a dtml-return tag. It's still not what you want. If you want to redirect the user, use dtml-call. If you want to return the output of another object, use dtml-var. There are precious few cases where dtml-return is correct... so few, in fact, you could use Zope for a couple years straight and easily forget it exists. :-) Dylan
Dylan Reinhardt wrote:
On Fri, 2003-08-01 at 08:47, Dylan Reinhardt wrote:
There is no dtml-return. You want dtml-call.
Grr... sorry. Of course there *is* a dtml-return tag.
It's still not what you want.
If you want to redirect the user, use dtml-call. If you want to return the output of another object, use dtml-var.
There are precious few cases where dtml-return is correct... so few, in fact, you could use Zope for a couple years straight and easily forget it exists. :-)
Hehe. You can also use Zope and easyly forget that DTML exists ;) At least for templates and logic. For that redirect issue - one should note that the page is indead calculated and rendered, since the redirect-call only sets a HTTP-HEader. So if content of page is confidental, just "jump out" with return after redirect, or use raise "Redirect","path..." String Exceptions are ugly, but Zopes roots go back to python1.4 or worser ;) HTH Tino
On Fri, 2003-08-01 at 12:16, Tino Wildenhain wrote:
Dylan Reinhardt wrote:
On Fri, 2003-08-01 at 08:47, Dylan Reinhardt wrote: There are precious few cases where dtml-return is correct... so few, in fact, you could use Zope for a couple years straight and easily forget it exists. :-)
Hehe. You can also use Zope and easyly forget that DTML exists ;) At least for templates and logic.
Guess I walked into that one... :-) Dylan
Thank you for your help, but... I have simplified my code, replaced dtml-return for dtml-call... and it still doesn´t work. 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> So I first check if the user has entered a value for txtCertificado, and return with an error message if it is not the case. The program does it right. Then I check for txtCertificado in the database (with th ZSQL method BuscaCertificado) and if it is found, it returns with an error message. The program also does it right. But when it finds the third case (there is a value for txtCertificado, and it is not already in the database) it does nothing. Instead of going to URL1+'/IC', it just shows a blank page. I really can't understand what could be the problem, because the logic seems so simple. Just in case that it matters, I am using Zope 2.6.1 on Windows. Borja Prieto Alanta
-----Mensaje original----- De: zope-admin@zope.org [mailto:zope-admin@zope.org]En nombre de Dylan Reinhardt Enviado el: viernes, 01 de agosto de 2003 22:46 Para: Tino Wildenhain CC: Borja Prieto; zope@zope.org Asunto: Re: [Zope] Problem with dtml-if sequence-start
On Fri, 2003-08-01 at 12:16, Tino Wildenhain wrote:
Dylan Reinhardt wrote:
On Fri, 2003-08-01 at 08:47, Dylan Reinhardt wrote: There are precious few cases where dtml-return is correct... so few, in fact, you could use Zope for a couple years straight and easily forget it exists. :-)
Hehe. You can also use Zope and easyly forget that DTML exists ;) At least for templates and logic.
Guess I walked into that one... :-)
Dylan
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
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
Dear Dylan Thank you for your help. It works all right now. Best regards Borja Prieto Alanta
-----Mensaje original----- De: zope-admin@zope.org [mailto:zope-admin@zope.org]En nombre de Dylan Reinhardt Enviado el: lunes, 04 de agosto de 2003 6:05 Para: Borja Prieto CC: zope@zope.org Asunto: RE: [Zope] Problem with dtml-if sequence-start
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
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Borja Prieto -
Dylan Reinhardt -
Tino Wildenhain