Server-side redirecting?
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
Michael Ekstrand wrote:
<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())
How are you passing the REQUEST/RESPONSE keyword variables? When I am doing what you are trying, I usually have code that looks like: return self.pbtovgplotform(self, REQUEST) A couple of notes here: 1 - Using self.pbtovgplotform means that the form will be acquired, which might help you or not (I'm not sure). 2 - Pass "self" as the first argument to the method call These two items together should get around the errors using the "_" namespace. OTOH, I would normally use REQUEST.getitem() instead of the _.getitem() ... HTH, JZ
participants (2)
-
John Ziniti -
Michael Ekstrand