Oh, that's good to know! Thanks!
On Jun 19, 2012 10:22 PM, "Michael Merickel" <[email protected]> wrote:
> So the generic (supported) way to write a decorator in pyramid that
> will work with any view is to use the decorator argument to add_view
> or view_config. This allows your decorator to have a consistent
> signature no matter whether the actual view is a method, or a function
> that accepts either (context, request) or just (request).
>
> def my_decorator(wrapped):
> def _wrapper(context, request):
> print("I'm totally decorated, man")
> response = wrapped(context, request)
> print("You *were* totally decorated, man")
> return response
> return _wrapper
>
> This allows all of the below view signatures to work.
>
> @view_config(..., decorator=my_decorator)
> def my_view(request):
> return {}
>
> @view_config(..., decorator=my_decorator)
> def my_view2(context, request):
> return {}
>
> class FooHandler(object):
> def __init__(self, request):
> self.request = request
>
> @view_config(..., decorator=my_decorator)
> def other_view(self):
> return {}
>
> On Tue, Jun 19, 2012 at 10:57 AM, Max Avanov <[email protected]>
> wrote:
> > I need to perform some manipulations with request object inside a
> decorator
> > wrapper. How can I access it?
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "pylons-discuss" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/pylons-discuss/-/Kq-R-mZCuDYJ.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/pylons-discuss?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.