Anyone: I've just run across something interesting and I'm not sure if this is by design. Consider the following in a DTML Document: --------------------------------------------------------- <dtml-call Session> #SQLSession instance <dtml-if "REQUEST.has_key('blah')"> <dtml-if "REQUEST.has_key('test')"> <dtml-call "SESSION.set('test',test)"> </dtml-if> <dtml-call "RESPONSE.redirect('nextpage')"> </dtml-if> <dtml-var standard_html_header> <dtml-if "SESSION.has_key('test')"> <dtml-call "SESSION.delete('test')"> </dtml-if> ..bunch of dtml/html <dtml-var standard_html_footer> --------------------------------------------------------- ok. So, when I wrote this, I figured that: when 'blah' exists, and 'test' exists, it will store 'test' in my mySQL database and then redirect to 'nextpage'... however, if 'blah' does not exist, then the document will be display, and if 'test' is stored as a SQLSession variable, then 'test will get deleted from the database... confused yet? Check this out... everything works as figured, *except* AFTER the response.redirect, the code: <dtml-if "SESSION.has_key('test')> <dtml-call "SESSION.delete('test')> </dtml-if> runs, effectively deleting test from the database after the RESPONSE.redirect. I've checked, double, and triple checked... I know this is happening, b/c if I remove the session.delete code 'test' is in the db. Am I crazy, or is this by design? Any info would be greatly appreciated. Andrew Williams <scratching his head...> ___________________________________________________________________________ Visit http://www.visto.com/info, your free web-based communications center. Visto.com. Life on the Dot.
This is by design. Just because you call a function that tells your browser to make another request, doesn't mean execution will stop, even if it "seems" like it should.
From the Advanced DTML chapter:
"Another upshot of using the return tag is that DTML execution will stop after the return tag." Try adding <dtml-return> after the redirect and you should get what you expect. _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Andrew Williams Sent: Thursday, February 22, 2001 6:28 PM To: zope@zope.org Subject: [Zope] SQLSession and RESPONSE.redirect
Check this out... everything works as figured, *except* AFTER the response.redirect, the code: <dtml-if "SESSION.has_key('test')> <dtml-call "SESSION.delete('test')> </dtml-if> runs, effectively deleting test from the database after the RESPONSE.redirect.
I've checked, double, and triple checked... I know this is happening, b/c if I remove the session.delete code 'test' is in the db.
Am I crazy, or is this by design?
-----Original Message----- From: Ron Bickers [mailto:rbickers@logicetc.com] Sent: Thursday, February 22, 2001 11:57 PM To: ajwms@visto.com; zope@zope.org Subject: RE: [Zope] SQLSession and RESPONSE.redirect
Try adding <dtml-return> after the redirect and you should get what you expect.
Oops. It looks like <dtml-return> requires something to be returned. Try <dtml-return expr="1"> or, instead of dtml-call RESPONSE.redirect, just <dtml-return "RESPONSE.redirect(...)"> _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
participants (2)
-
Andrew Williams -
Ron Bickers