def __new__(cls, name, bases, d): def find_method(m): for base in bases: try: return getattr(base, m) except AttributeError: pass raise AttributeError("No bases have method '{}'".format(m)) for view, url, methods in [ ('index_view', '/', None), ('create_view', '/new/', ('GET', 'POST')), ('edit_view', '/edit/', ('GET', 'POST')), ('details_view', '/details/', None), ('delete_view', '/delete/', ('POST',)), ('action_view', '/action/', ('POST',)), ('export', '/export/<export_type>/', None)]: if methods is not None: d[view] = basic_auth.required( expose(url, methods=methods)( find_method(view))) else: d[view] = basic_auth.required( expose(url)( find_method(view))) return super().__new__(cls, name, bases, d)
def __new__(cls, name, bases, d): def find_method(m): for base in bases: try: return getattr(base, m) except AttributeError: pass raise AttributeError("No bases have method '{}'".format(m)) for view, url, methods in [('index_view', '/', None), ('create_view', '/new/', ('GET', 'POST')), ('edit_view', '/edit/', ('GET', 'POST')), ('details_view', '/details/', None), ('delete_view', '/delete/', ('POST', )), ('action_view', '/action/', ('POST', )), ('export', '/export/<export_type>/', None)]: if methods is not None: d[view] = basic_auth.required( expose(url, methods=methods)(find_method(view))) else: d[view] = basic_auth.required(expose(url)(find_method(view))) return super().__new__(cls, name, bases, d)
class MyAdminIndexView(AdminIndexView): @expose('/')