how to avoid a redirect ?
or better how to finish a transaction programmaticaly ? I have a form, which list object and a checkbox beside each line, where I can mark objects for deletion. The delete-method deletes the checked objects but when I just do a return context.listForm() in my delete-method, the deleted objects still show up, only after a reload of the form they are really gone. if I do a return context.REQUEST.RESPONSE.redirect(context.REQUEST.get("HTTP_REFERER")) the list is directly refreshed. I assume, that's because the transaction is not finished in the first case. So my question is there a way to finish the transaction programmatically ? -- Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Telefon: +49-2464-8851, FAX: +49-2464-905163 --------------------------------------------------------------------
When you want to immediately display the results of changing information in a form, I find it works best when a form submits to itself rather than to an intermediate target. Doing this avoids the caching/latency issue altogether. For example: ---------------- <!-- Process changes first --> <dtml-if is_form_submit> Do form processing here... </dtml-if> <!-- Draw the form with the latest data available --> <form target=<dtml-var URL> method=post> <input type=hidden name=is_form_submit value=1> Form code goes here... </form> ---------------- HTH, Dylan
that helps in the case, where one does not change any objects in the ZODB, but if one for example deletes objects in the formprocessing, which you can mark in the formcode, then the deleted objects still show up in the form, cause it is all done in one transaction. Dylan Reinhardt wrote:
When you want to immediately display the results of changing information in a form, I find it works best when a form submits to itself rather than to an intermediate target. Doing this avoids the caching/latency issue altogether.
For example:
---------------- <!-- Process changes first -->
<dtml-if is_form_submit> Do form processing here... </dtml-if>
<!-- Draw the form with the latest data available -->
<form target=<dtml-var URL> method=post> <input type=hidden name=is_form_submit value=1> Form code goes here... </form> ----------------
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 )
-- Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Telefon: +49-2464-8851, FAX: +49-2464-905163 --------------------------------------------------------------------
On Sat, 2003-05-17 at 01:34, Joachim Schmitz wrote:
that helps in the case, where one does not change any objects in the ZODB, but if one for example deletes objects in the formprocessing, which you can mark in the formcode, then the deleted objects still show up in the form, cause it is all done in one transaction.
Oh... I see what you're getting at. Sorry for the confusion. That *is* a good argument for a redirect. Unfortunately, (IIRC) some browsers complain about being redirected on a POST. If you want to accomplish the same thing without using a redirect, you could return an intermediate "changes accepted" screen that does an HTTP-EQUIV refresh to your form after 1 or 2 seconds. HTH Dylan
There is nothing wrong with performing the redirect. I'd even say this is the exact thing to do in a situation like yours. Stefan On Freitag, Mai 16, 2003, at 22:44 Europe/Vienna, Joachim Schmitz wrote:
or better how to finish a transaction programmaticaly ?
I have a form, which list object and a checkbox beside each line, where I can mark objects for deletion. The delete-method deletes the checked objects but when I just do a
return context.listForm()
in my delete-method, the deleted objects still show up, only after a reload of the form they are really gone.
if I do a
return context.REQUEST.RESPONSE.redirect(context.REQUEST.get("HTTP_REFERER"))
the list is directly refreshed. I assume, that's because the transaction is not finished in the first case. So my question is there a way to finish the transaction programmatically ?
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Stefan H. Holek
return context.REQUEST.RESPONSE.redirect(context.REQUEST.get("HTTP_REFERER"))
There is nothing wrong with performing the redirect. I'd even say this is the exact thing to do in a situation like yours.
I've been doing things like this for a long time and have never gotten a complaint about it not working in a particular browser. Even my simplest forms usually proceed as follows: form.html --> submit processed by a Python Script --> Python Script redirects to thankyou.html The biggest reason I started doing this is to prevent a subsequent browser "reload" from resubmitting the form since in the above case it will just reload the thankyou.html page. _______________________ Ron Bickers Logic Etc, Inc.
Joachim Schmitz wrote at 2003-5-16 20:44 +0000:
or better how to finish a transaction programmaticaly ?
You may look at my "EmulatedRedirect" External Method: <http://www.dieter.handshake.de/pyprojects/zope> Dieter
Dieter Maurer wrote:
Joachim Schmitz wrote at 2003-5-16 20:44 +0000:
or better how to finish a transaction programmaticaly ?
You may look at my "EmulatedRedirect" External Method:
I tried to use it, but if I call it with: return context.emulateRedirectURL('content/list',transaction="commit") I always get a Not found error: User Name (User Id) company-admin (company-admin) Request URL http://company.vcs.aixtraware.de/content Exception Type NotFound Exception Value http://company.vcs.aixtraware.de/content [ /list ] eventhough the object http://company.vcs.aixtraware.de/content/list exists this is with 2.6.1 under Linux -- Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Telefon: +49-2464-8851, FAX: +49-2464-905163 --------------------------------------------------------------------
Joachim Schmitz wrote at 2003-5-20 20:05 +0200:
Dieter Maurer wrote:
Joachim Schmitz wrote at 2003-5-16 20:44 +0000:
or better how to finish a transaction programmaticaly ?
You may look at my "EmulatedRedirect" External Method:
I tried to use it, but if I call it with:
return context.emulateRedirectURL('content/list',transaction="commit")
I always get a Not found error:
User Name (User Id) company-admin (company-admin) Request URL http://company.vcs.aixtraware.de/content Exception Type NotFound Exception Value http://company.vcs.aixtraware.de/content [ /list ]
eventhough the object
Are your running in non-debug mode? HTTP/1.1 allows servers to cheat with the "NotFound" HTTP response. It can be used whenever the server does not want to give more precise information about the problem. Try running in debug mode. If this does not help, debug the "traverse" in "emulateRedirectURL". Dieter
participants (5)
-
Dieter Maurer -
Dylan Reinhardt -
Joachim Schmitz -
Ron Bickers -
Stefan H. Holek