'Because of the way class based views create a closure around the
instantiated view, we need to totally reimplement `.as_view`,
and slightly modify the view function that is created and returned.'

@classonlymethod
def as_view(cls, actions=None, **initkwargs):

    cls.suffix = None
    if (not actions):
        raise TypeError(u"The    `actions`    argument    must    be    provided    when    calling    `.as_view()`    on    a    ViewSet.    For    example    `.as_view({'get':    'list'})`")
    for key in initkwargs:
        if (key in cls.http_method_names):
            raise TypeError((u"You    tried    to    pass    in    the    %s    method    name    as    a    keyword    argument    to    %s().    Don't    do    that." % (key, cls.__name__)))
        if (not hasattr(cls, key)):
            raise TypeError((u'%s()    received    an    invalid    keyword    %r' % (cls.__name__, key)))
    def view(request, *args, **kwargs):
        self = cls(**initkwargs)
        self.action_map = actions
        for (method, action) in actions.items():
            handler = getattr(self, action)
            setattr(self, method, handler)
        if (hasattr(self, u'get') and (not hasattr(self, u'head'))):
            self.head = self.get
        self.request = request
        self.args = args
        self.kwargs = kwargs
        return self.dispatch(request, *args, **kwargs)
    update_wrapper(view, cls, updated=())
    update_wrapper(view, cls.dispatch, assigned=())
    view.cls = cls
    view.initkwargs = initkwargs
    view.suffix = initkwargs.get(u'suffix', None)
    view.actions = actions
    return csrf_exempt(view)
