[Zope] Server-side redirecting?

Michael Ekstrand michael-zope at elehack.net
Wed Jul 14 14:42:54 EDT 2004


I'm writing an ExternalMethod to handle some form data. Its job is 
simple - sanity-check the data (no, you can't schedule an event for 
June 31), and, if the data is good, pass it off to an SQL method.

That all works correctly. The problem comes in with the error handling. 
If there's an error, what I'm trying to do is set a variable in the 
REQUEST object to contain a dictionary of information related to the 
error (the user's entered data, and error messages). It's then supposed 
to pass control back to the form, to redisplay the form with the data 
and error messages. I can't seem to get this working. If I do 
RESPONSE.redirect(), it sends the redirect to the client, so I lose the 
data stashed in my REQUEST. The form is generated by the index_html 
method of the folder; if I call the folder, and try to return the 
result, it complains about no __call__ method. If I return str(folder), 
it complains that it can't find the resource "Folder at ID 
<weirdnumber>". If I return folder.index_html(), it complains that it 
can't find the REQUEST object... it appears that the DTML method 
index_html completely loses its acquisition context (if I provide 
REQUEST and RESPONSE keyword variables, it then complains in my usage 
of _.getitem())

Is there a way I can reliably pass control around on the server? I've 
been able to succesfully do it when the destination is a page template, 
but no such luck with DTML methods. And I can't seem to find anything 
like DTML's render() function outside of DTML - is there some kind of 
generalized render() function somewhere I can use? or can I just access 
the one provided to DTML code somehow?

TIA,
Michael


More information about the Zope mailing list