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'])
...