Change URL after SQL statement execution?
Good Morning List. I am trying to do something very simple. I have three files: 1/An SQL statement that I pass parameters too 2/A form that I use to collect the parameters that are passed to the script 3/A Script that is called from the form to run the SQL statement 4/A Page Template
From my python script I call the SQL using:
context.MySQLStatement(first_name=First, last_name=Last) It works fine with regards to running the SQL but if the resulting page is refreshed it runs the SQL again. How do I avoid this? If I cange the URL I figure it avoids this problem but dont know how to do this? Any help would be much appreciated, Kind Regards, Rob
On Wed, 19 Nov 2003 10:03:43 +0000 GMT RI Dunfey asked the Zope mailinglist about the following:
From my python script I call the SQL using:
context.MySQLStatement(first_name=First, last_name=Last)
It works fine with regards to running the SQL but if the resulting page is refreshed it runs the SQL again. How do I avoid this? If I cange the URL I figure it avoids this problem but dont know how to do this?
http-redirect from the script to your template at (4). context.REQUEST.RESPONSE.redirect(context.4yourPageTeplate.absolute_url()) :) -- __________________________________________________________________ Geir Bækholt · Interaction Architect · Plone Solutions Development · Training · Support · http://www.plonesolutions.com __________________________________________________________________
On Wed, 2003-11-19 at 02:20, Geir Bækholt wrote:
On Wed, 19 Nov 2003 10:03:43 +0000 GMT RI Dunfey asked the Zope mailinglist about the following:
It works fine with regards to running the SQL but if the resulting page is refreshed it runs the SQL again. How do I avoid this? If I cange the URL I figure it avoids this problem but dont know how to do this?
http-redirect from the script to your template at (4). context.REQUEST.RESPONSE.redirect(context.4yourPageTeplate.absolute_url())
This answers your question, but I doubt it will solve your problem... you'll just have the same issue at a new address. Since your refreshed POST will be identical to the original, you'll have to solve this server-side. One thing you could do is use a session variable to associate a user cookie with the last time they ran your query. Then make your Python script check for this value and return None when not enough time has passed. HTH, Dylan
On Wed, 2003-11-19 at 06:39, Dylan Reinhardt wrote:
On Wed, 2003-11-19 at 02:20, Geir Bækholt wrote:
On Wed, 19 Nov 2003 10:03:43 +0000 GMT RI Dunfey asked the Zope mailinglist about the following:
It works fine with regards to running the SQL but if the resulting page is refreshed it runs the SQL again. How do I avoid this? If I cange the URL I figure it avoids this problem but dont know how to do this?
http-redirect from the script to your template at (4). context.REQUEST.RESPONSE.redirect(context.4yourPageTeplate.absolute_url())
This answers your question, but I doubt it will solve your problem... you'll just have the same issue at a new address.
Sorry... that was a brain fart. I think I shouldn't post to the list until after I've had my morning coffee. :-) Redirecting after you run the query will work fine. Dylan
participants (3)
-
Dylan Reinhardt -
Geir Bækholt -
RI Dunfey