AW: [Zope3-Users] "raise Redir(newurl)" not working - can someoneconfirm this?

Roger Ineichen dev at projekt01.ch
Sat Apr 19 08:05:23 EDT 2008


Hi Hermann

> Betreff: [Zope3-Users] "raise Redir(newurl)" not working - 
> can someoneconfirm this?
> 
> Hi,
> In my application, namely for URL-Rewriting for session 
> handling, I need to stop the current request and redirect to 
> another url (including the session key).
> 
> For that reason, I issue the following statement:
> 
> from zope.publisher.interfaces import Redirect raise 
> Redirect('http://my.new.url')

I always use self.request.response.redirect(url)

I'm not sure how raise Redirect works.

> Theoretically, this exception should be caught by the 
> publisher and a redirect should be done, unfortunately not in my case:
> 
> -------------
> Traceback (most recent call last):
>   File 
> "/local/home/dusty/Zope-3.4.0c1/lib/python/zope/publisher/publish.py",
> line 130, in publish
>     obj = request.traverse(obj)
> ....
>   File 
> "/home/dusty/prog/zope3-inst/lib/python/my_app/session.py", 
> line 72, in getClientId
>     raise Redirect(redir_url)
> Redirect: 
> Location: 
> /++session++VLdODjCYl90YmQwdNG6hvdiT11UZS3oly5kXonWYLHdGHloxvT
> shQs/favicon.ico
> --------------

Are you trying to redirect to the favicon.ico?

> I don't know why this happens, *maybe* that's due to 
> inclusion of some 3rd party packages, e.g. z3c.layer.pagelet?
> 
> To confirm this, I'd like to know if this scenario is only 
> happening for me, so, can you please simply insert the above 
> statement in some arbitrary view and tell me if it works?

I'm not 100% sure but,

Note, if you use redirect you have to take care when you 
are doing this. You can only do this in the view call
but not if the pagelet renders the template, because that's
too late. This is not pagelet specific, that's also the case 
if you render a template in a BrowserPage?

Regards
Roger Ineichen

> Best Regards,
> Hermann
> 
> --
> hermann at qwer.tk
> GPG key ID: 299893C7 (on keyservers)
> FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 



More information about the Zope3-users mailing list