Redirecting from Python?
Greetings! I'm working on a Product, and I'd like to be able to do a RESPONSE.redirect() from inside the Python code. What I had was basically this: <dtml-if "some number of conditions"> View the page . . . <dtml-else> <dtml-call "RESPONSE.redirect('blahblahblah')"> </dtml-if> This works fine, but rather than having that sitting out in DTML-land, I figured I could put the conditions in the Python code and simplify the if statement, so all I'd have to do is: <dtml-if someConditions> View the page . . . </dtml-if> The Python code I was hoping would accomplish this was: def someConditions(self): if (some number of conditions): return 1 else: self.REQUEST.RESPONSE.redirect('blahblahblah') My problem is that the redirect just doesn't happen. I've had this function return values and the like, so I know it's parsing my conditions correctly, and I can even do a "return self.REQUEST.RESPONSE.redirect" and have the function returned back into my page, but it won't actually redirect. Any ideas? Thanks in advance . . . -CJ
Are you doing a dtml-var or dtml-call to call your external method? I believe you need a dtml-call. --jfarr "Perl is worse than Python because people wanted it worse." Larry Wall, 14 Oct 1998 ----- Original Message ----- From: Christopher J. Kucera <ckucera@globalcrossing.com> To: <zope@zope.org> Sent: Friday, August 04, 2000 10:49 AM Subject: [Zope] Redirecting from Python?
Greetings!
I'm working on a Product, and I'd like to be able to do a RESPONSE.redirect() from inside the Python code. What I had was basically this:
<dtml-if "some number of conditions"> View the page . . . <dtml-else> <dtml-call "RESPONSE.redirect('blahblahblah')"> </dtml-if>
This works fine, but rather than having that sitting out in DTML-land, I figured I could put the conditions in the Python code and simplify the if statement, so all I'd have to do is:
<dtml-if someConditions> View the page . . . </dtml-if>
The Python code I was hoping would accomplish this was:
def someConditions(self): if (some number of conditions): return 1 else: self.REQUEST.RESPONSE.redirect('blahblahblah')
My problem is that the redirect just doesn't happen. I've had this function return values and the like, so I know it's parsing my conditions correctly, and I can even do a "return self.REQUEST.RESPONSE.redirect" and have the function returned back into my page, but it won't actually redirect.
Any ideas? Thanks in advance . . .
-CJ
_______________________________________________ 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 )
Jonothan Farr wrote:
Are you doing a dtml-var or dtml-call to call your external method? I believe you need a dtml-call.
I've tried both. :) Other things I've tried: * Explicitly passing in the REQUEST object * Explicitly passing in the RESPONSE object * slapping a "return" in front of the call Also, it's not really an external method . . . It's a method defined in the product's class. (Perhaps that's significant somehow.) Thanks for the info, though . . . :) -CJ
Hi! On Fri, Aug 04, 2000 at 12:49:52PM -0500, Christopher J. Kucera wrote:
I'm working on a Product, and I'd like to be able to do a RESPONSE.redirect() from inside the Python code. What I had was basically this:
[...]
def someConditions(self): if (some number of conditions): return 1 else: self.REQUEST.RESPONSE.redirect('blahblahblah')
You actually should use something like this: raise 'Redirect','http://my.server/my/path' -- christian -- Christian Scholz MrTopf@IRC COM.lounge http://comlounge.net/ communication & design cs@comlounge.net
Christian Scholz wrote:
You actually should use something like this:
raise 'Redirect','http://my.server/my/path'
Ah yes! This works wonderfully. Thanks much! :) -CJ
participants (3)
-
Christopher J. Kucera -
cs@comlounge.net -
Jonothan Farr