

def wrap_class_based_view(fun, injector):
    cls = fun.view_class
    name = fun.__name__
    closure_contents = (c.cell_contents for c in fun.__closure__)
    fun_closure = dict(zip(fun.__code__.co_freevars, closure_contents))
    try:
        class_kwargs = fun_closure['class_kwargs']
    except KeyError:
        flask_restful_api = fun_closure['self']
        fun = fun_closure['resource']
        fun_closure = {
            
        }
        class_kwargs = {
            
        }
    else:
        flask_restful_api = None
        class_args = fun_closure.get('class_args')
        assert (not class_args), 'Class args are not supported, use kwargs instead'
    if (flask_restful_api and flask_restplus and isinstance(flask_restful_api, flask_restplus.Api)):
        if ('api' in class_kwargs):
            raise AssertionError('api keyword argument is reserved')
        class_kwargs['api'] = flask_restful_api

    def view(*args, **kwargs):
        self = injector.create_object(cls, additional_kwargs=class_kwargs)
        return self.dispatch_request(*args, **kwargs)
    if cls.decorators:
        view.__name__ = name
        view.__module__ = cls.__module__
        for decorator in cls.decorators:
            view = decorator(view)
    view.view_class = cls
    view.__name__ = name
    view.__doc__ = cls.__doc__
    view.__module__ = cls.__module__
    view.methods = cls.methods
    fun = view
    if flask_restful_api:
        return wrap_flask_restful_resource(fun, flask_restful_api, injector)
    return fun

dataset/ETHPy150Open alecthomas/flask_injector/flask_injector.py wrap_class_based_view/original