| 101 | "mutually exclusive arguments." % (cls.__name__)) |
| 102 | |
| 103 | def view(request, *args, **kwargs): |
| 104 | self = cls(**initkwargs) |
| 105 | |
| 106 | if 'get' in actions and 'head' not in actions: |
| 107 | actions['head'] = actions['get'] |
| 108 | |
| 109 | # We also store the mapping of request methods to actions, |
| 110 | # so that we can later set the action attribute. |
| 111 | # eg. `self.action = 'list'` on an incoming GET request. |
| 112 | self.action_map = actions |
| 113 | |
| 114 | # Bind methods to actions |
| 115 | # This is the bit that's different to a standard view |
| 116 | for method, action in actions.items(): |
| 117 | handler = getattr(self, action) |
| 118 | setattr(self, method, handler) |
| 119 | |
| 120 | self.request = request |
| 121 | self.args = args |
| 122 | self.kwargs = kwargs |
| 123 | |
| 124 | # And continue as usual |
| 125 | return self.dispatch(request, *args, **kwargs) |
| 126 | |
| 127 | # take name and docstring from class |
| 128 | update_wrapper(view, cls, updated=()) |