List Info

Thread: redirect bug for __before__ methods in controllers




redirect bug for __before__ methods in controllers
country flaguser name
United States
2007-05-30 08:31:06
I was trying to do a redirect_to call in the __before__
method a
controller. Pylons isn't catching the HTTPFound exception
and doing
the redirect.

in pylons/controllers.py : in both the Controller and the
WSGIController classes

        if hasattr(self, '__before__'):
            self._inspect_call(self.__before__, **kargs)

        try:
            response = self._dispatch_call()
        except HTTPException, httpe:
            response = httpe.response(environ)
        if hasattr(self, '__after__'):
            self.response = response
            self._inspect_call(self.__after__)

        return response


the __before__ call is outside of the try:. Is there any
particular
reason for this? Should I not be redirecting from a
__before__ method?
Would it make sense to move the call to __before__ inside
the try? I
made the change and it seemed to work...

Thanks,
Mike


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: redirect bug for __before__ methods in controllers
country flaguser name
United States
2007-05-30 15:01:30

On May 30, 2007, at 6:31 AM, capeddugmail.com wrote:

>
> I was trying to do a redirect_to call in the __before__
method a
> controller. Pylons isn't catching the HTTPFound
exception and doing
> the redirect.
>
> in pylons/controllers.py : in both the Controller and
the
> WSGIController classes
>
>         if hasattr(self, '__before__'):
>             self._inspect_call(self.__before__,
**kargs)
>
>         try:
>             response = self._dispatch_call()
>         except HTTPException, httpe:
>             response = httpe.response(environ)
>         if hasattr(self, '__after__'):
>             self.response = response
>             self._inspect_call(self.__after__)
>
>         return response
>
>
> the __before__ call is outside of the try:. Is there
any particular
> reason for this? Should I not be redirecting from a
__before__ method?
> Would it make sense to move the call to __before__
inside the try? I
> made the change and it seemed to work...

This was a bug in only trunk, I just fixed it in r2014.

0.9.5-release uses the httpexceptions middleware, and
doesn't have  
this problem. Whereas trunk doesn't require it and handles
converting  
the HTTPExceptions itself.

Thanks for pointing this out

--
Philip Jenvey



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )