decorator.py
739 Bytes
import venusian
from .structure import RENDERER
# view decorator
class csv_method:
def __init__(self, **kw):
self.kw = kw
def __call__(self, wrapped):
kw = self.kw.copy()
depth = kw.pop('_depth', 0)
def callback(context, name, ob):
config = context.config.with_package(info.module)
config.add_view(view=ob, renderer=RENDERER, **kw)
info = venusian.attach(
wrapped, callback, category='pyramid', depth=depth + 1)
if info.scope == 'class':
# ensure that attr is set if decorating a class method
kw.setdefault('attr', wrapped.__name__)
kw['_info'] = info.codeinfo # fbo action_method
return wrapped