view_config does not work with inheritance. One option if you really want
something like this is to write a class decorator with venusian that can
automatically register certain views for you (this is similar to how
cornice works).


On Thu, Mar 28, 2013 at 6:55 AM, Tjelvar <[email protected]> wrote:

> Dear all,
>
> Some of my resources will have identical views for some request methods
> (see below for an example). I would therefore like to be able to inherit
> these from a base class. However, the code below does not appear to work
> (e.g. POST returns 404 Not Found rather than 405 Method Not Allowed).
>
> Any thoughts on how I could achieve type behaviour?
>
> class _BaseView(object):
>
>     @view_config(request_method='OPTIONS')
>     def options(self):
>         "Return OPTIONS response."
>         return Response(allow=['HEAD', 'GET', 'OPTIONS'])
>
>     @view_config()
>     def other_request_methods(self):
>         "Disallow other request methods."
>         return HTTPMethodNotAllowed()
>
> @view_defaults(route_name='real_view')
> class RealView(_BaseView):
>
>     def __init__(self, request):
>         self.request = request
>
>     @view_config(request_method='GET')
>     def get(self):
>         return Response('This is a view...')
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to