示例#1
0
文件: app.py 项目: tuna/registr
    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)
示例#2
0
    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)
示例#3
0
class MyAdminIndexView(AdminIndexView):
    @expose('/')