Hi all
The situation
------------------OneZPT------------------ <FORM action SomePythonScript> selections </FORM> -----------------------------------------
---------------SomePythonSript----- results=SomeSQL(pass selections from OneZPT> RESPONSE.redirect(AnotherZPT) -----------------------------------------
I need to get the results in AnotherZPT.
-------------AnotherZPT-------------- <table> <tr somehow get the results from SomePythonScript triggered by OneZPT> <td> display here </td> </tr> </table> ----------------------------------------- What is the way out ?
This is a compromise solution for my requirements. Earlier, I wanted to return the results to OneZPT where I would have rendered. This seems to be a bit tricky to me at this moment.
TIA Chetan
You can't, but you can. It depends on what your other requirements are. Here's three suggestions: 1) Don't redirect. Render the ZPT direction in the python script. This will show the python scrpit in the clients browser window, but is most secure and will have the best performance (since there is no round trip to the client). 2) Use a session. Stuff the data into the session object, redirect, and pray it's there when the second page gets requested. This makes me nervous for some reason, probably because the whole notion of sessions is nebulous for the web. 3) Embed the data into the redirect URL. If it's small enough, you could just tack them on as GET style arguments. This has the disadvantage of exposing said data directly to the user and will have problems with even moderate amounts of data. Even better, why not make the ZPT the target of the form, then call your SQL stuff from the form? Your solution seems rather roundabout to me.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Chetan Kumar Sent: Tuesday, August 20, 2002 11:45 AM To: zope@zope.org Subject: [Zope] Redirect with results of script to another ZPT
Hi all
The situation
------------------OneZPT------------------ <FORM action SomePythonScript> selections </FORM> -----------------------------------------
---------------SomePythonSript----- results=SomeSQL(pass selections from OneZPT> RESPONSE.redirect(AnotherZPT) -----------------------------------------
I need to get the results in AnotherZPT.
-------------AnotherZPT-------------- <table> <tr somehow get the results from SomePythonScript triggered by OneZPT> <td> display here </td> </tr> </table> ----------------------------------------- What is the way out ?
This is a compromise solution for my requirements. Earlier, I wanted to return the results to OneZPT where I would have rendered. This seems to be a bit tricky to me at this moment.
TIA Chetan
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Charlie Reiman writes:
You can't, but you can. It depends on what your other requirements are. Here's three suggestions:
... 2) Use a session. Stuff the data into the session object, redirect, and pray it's there when the second page gets requested. This makes me nervous for some reason, probably because the whole notion of sessions is nebulous for the web. Sessions will not store the results of Z SQL Methods. They are not persistent. They need to be transformed into much simpler objects. ... Even better, why not make the ZPT the target of the form, then call your SQL stuff from the form? Your solution seems rather roundabout to me.
You might also find "emulateRedirect" useful: <http://www.dieter.handshake.de/pyprojects/zope> Dieter
On Wed, Aug 21, 2002 at 12:14:51AM +0530, Chetan Kumar wrote:
Hi all
The situation
------------------OneZPT------------------ <FORM action SomePythonScript> selections </FORM> -----------------------------------------
---------------SomePythonSript----- results=SomeSQL(pass selections from OneZPT> RESPONSE.redirect(AnotherZPT) -----------------------------------------
I need to get the results in AnotherZPT.
-------------AnotherZPT-------------- <table> <tr somehow get the results from SomePythonScript triggered by OneZPT> <td> display here </td> </tr> </table> ----------------------------------------- What is the way out ?
This is a compromise solution for my requirements. Earlier, I wanted to return the results to OneZPT where I would have rendered. This seems to be a bit tricky to me at this moment.
TIA Chetan
What I do is have the action for the form in OneZPT point to AnotherZPT. Then from AnotherZPT you can call SomePythonScript which will call the ZSQL method and do any data manipulation necessary, and then return the data to AnotherZPT. This works nicely because you get the benefit of having access to the REQUEST variables in both AnotherZPT and SomePythonScript without having to pass it around. I think that you could use the same technique to return the result to OneZPT instead of AnotherZPT if that is what you really want to do. You could have the form action point to OneZPT and give the submit button of OneZPT a distinct name like hasbeensubmitted or something. Then set up a tal:condition to test for hasbeensubmitted. If it is there, call SomePythonScript to process the ZSQL and return the results to OneZPT and go on from there. Hope that helps, Chris -- Chris Meyers Huttleston Data Design 7941 Tree Lane Suite 200 Madison WI 53717
Hello Chetan, Tuesday, August 20, 2002, 8:44:51 PM, you wrote: CK> Hi all
The situation [snip]....
the simple, and IMHO most clean way to do this : ------------------OneZPT------------------ <FORM action SomePythonScript> selections </FORM> ----------------------------------------- ---------------SomePythonSript----- results=SomeSQL(pass selections from OneZPT> return AnotherZPT(results=results) ----------------------------------------- -------------AnotherZPT-------------- <table> <tr tal:repeat="myrows options/results">/tr> i use this approach a lot (or more complex variations of it) - you can easily make SomePythonSript return the original OneZPT if the form-data has errors , and branch to different AnotherZPTs on any imaginable condition.. - By far the most flexible solution , at least.. hth :) -- Geir Bækholt web-developer geirh@funcom.com funcom oslo | webdev-team
Geir Bækholt wrote:
SNIP
---------------SomePythonSript----- results=SomeSQL(pass selections from OneZPT> return AnotherZPT(results=results) -----------------------------------------
The return AnotherZPT(results=results) will not work unless defined in some other zope-sensible way (I do not know precisely what this would be). TIA Chetan
participants (5)
-
Charlie Reiman -
Chetan Kumar -
Chris Meyers -
Dieter Maurer -
Geir Bækholt