Michael, thank you for all your help. I will experiment with the solution you proposed over the next week or so.
All the best, Tjelvar On Monday, April 1, 2013 5:34:24 PM UTC+1, Michael Merickel wrote: > > This isn't tested, but should basically handle what you've been asking > for, I think. > > https://gist.github.com/mmerickel/5286023 > > > On Mon, Apr 1, 2013 at 10:41 AM, Tjelvar <[email protected]<javascript:> > > wrote: > >> Dear Michael, >> >> Thank you for your reply. I have been reading up on decorators, venusian >> and cornice. However, I'm still struggling to put together something that >> works. >> >> I think that what I'm failing to do is to identify the route that the >> view should be added to. >> >> Does anyone have any idea why the code below does not work? >> >> Tjelvar >> >> ... >> >> def base_views(): >> def wrapper(klass): >> >> def _options(): >> >> "Return OPTIONS response." >> return Response(allow=['HEAD', 'GET', 'OPTIONS']) >> >> def callback(context, name, ob): >> config = context.config.with_package(info.module) >> config.add_view(_options, request_method='OPTIONS') >> >> info = venusian.attach(wrapper , callback, category='pyramid') >> >> return klass >> return wrapper >> >> @view_defaults(route_name='root') >> @base_views() >> class Root(object): >> >> def __init__(self, request): >> self.request = request >> >> # @view_config(request_method='OPTIONS') >> # def options(self): >> # "Return OPTIONS response." >> # return Response(allow=['HEAD', 'GET', 'OPTIONS']) >> >> ... >> >> >> >> >> >> On Thursday, March 28, 2013 8:15:49 PM UTC, Michael Merickel wrote: >>> >>> 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). >>> >>> >>> >>> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> 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.
