On 06/20/2012 11:01 AM, Max Avanov wrote:
Does the decorator argument of view_config support a list of decorators?
No, but:
http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/views/chaining_decorators.html
On Wednesday, June 20, 2012 9:21:47 AM UTC+4, Michael Merickel 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]
<mailto:[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
<https://groups.google.com/d/msg/pylons-discuss/-/Kq-R-mZCuDYJ>.
> To post to this group, send email to
[email protected]
<mailto:[email protected]>.
> To unsubscribe from this group, send email to
> [email protected]
<mailto:pylons-discuss%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en
<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 view this discussion on the web visit
https://groups.google.com/d/msg/pylons-discuss/-/8XmyG7RQZpoJ.
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.