[Zope] redirect request and the options property

Clemens Klein-Robbenhaar zope@zope.org
Thu, 12 Sep 2002 20:44:13 +0200 (CEST)


Borislav writes:
 > I have a python script that redirects the browser to a ZPT like this:
 > 
 > return context.REQUEST.RESPONSE.redirect(request.URL1 + '/myPage')
 > 
 > I woluld like to pass an argument to the ZPT that will be accessible 
 > through the 'options' property like this:
 > 
 > <p tal:condition="options/errorMessage | nothing" 
 > tal:content="options/errorMessage">Error message</p>
 > 
 > Is there a way to use the RESPONSE object to set the 'options' property 
 > before the redirect? Is the 'options' property user-accessible 
 > (writable) at all?

No way for the redirect. That starts a new request, and Youmust tell the 
client to send the data. The simplest way is to put them in the request:

return context.REQUEST.RESPONSE.redirect(request.URL1 + '/myPage?errorMessage='+errorMessage)

(errorMessage must be URL-encoded in this case ...)

and in the template say something like:

<p tal:condition="options/errorMessage | request/errorMessae | nothing"
   tal:content="options/errorMessage | request/errorMessage">Error message</p>


But why do you need the redirect at all? Does 
"context.myPage(errorMessage='some error message')" not work?

 > 
 > Another related issue: how can I redirect to a ZPT passing all form 
 > properties from the current request like in the following pattern:
 > 
 > HTML Form page -> action script that redirects -> Form handling page
 > 

Hm, looks like you need to store the data in the session ... that is
what is has been invented for ;-)

Cheers,
Clemens