diff options
| author | Tom Christie | 2011-05-17 09:15:35 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-05-17 09:15:35 +0100 |
| commit | bfbb8ceccf209d6cd11723ead11e820e96e0accd (patch) | |
| tree | c21b9920403f1850ef70ccac2cb3c3dbfe3b5105 /djangorestframework/mixins.py | |
| parent | 3f6b6e437bf24a55c33af5379b8ae89974edba57 (diff) | |
| parent | 40573b2793a49d68b89ea5b6c4bff0e13470cc0c (diff) | |
| download | django-rest-framework-bfbb8ceccf209d6cd11723ead11e820e96e0accd.tar.bz2 | |
Merge Marko's doc improvements.
Diffstat (limited to 'djangorestframework/mixins.py')
| -rw-r--r-- | djangorestframework/mixins.py | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/djangorestframework/mixins.py b/djangorestframework/mixins.py index 278d4d4d..e101b788 100644 --- a/djangorestframework/mixins.py +++ b/djangorestframework/mixins.py @@ -408,28 +408,6 @@ class AuthMixin(object): permission.check_permission(user) -########## - -class InstanceMixin(object): - """ - Mixin class that is used to identify a view class as being the canonical identifier - for the resources it is mapped too. - """ - - @classmethod - def as_view(cls, **initkwargs): - """ - Store the callable object on the resource class that has been associated with this view. - """ - view = super(InstanceMixin, cls).as_view(**initkwargs) - if 'resource' in initkwargs: - # We do a little dance when we store the view callable... - # we need to store it wrapped in a 1-tuple, so that inspect will treat it - # as a function when we later look it up (rather than turning it into a method). - # This makes sure our URL reversing works ok. - initkwargs['resource'].view_callable = (view,) - return view - ########## Resource Mixin ########## class ResourceMixin(object): @@ -449,6 +427,9 @@ class ResourceMixin(object): @property def CONTENT(self): + """ + Returns the cleaned, validated request content. + """ if not hasattr(self, '_content'): self._content = self.validate_request(self.DATA, self.FILES) return self._content @@ -474,6 +455,28 @@ class ResourceMixin(object): +########## + +class InstanceMixin(object): + """ + Mixin class that is used to identify a view class as being the canonical identifier + for the resources it is mapped too. + """ + + @classmethod + def as_view(cls, **initkwargs): + """ + Store the callable object on the resource class that has been associated with this view. + """ + view = super(InstanceMixin, cls).as_view(**initkwargs) + if 'resource' in initkwargs: + # We do a little dance when we store the view callable... + # we need to store it wrapped in a 1-tuple, so that inspect will treat it + # as a function when we later look it up (rather than turning it into a method). + # This makes sure our URL reversing works ok. + initkwargs['resource'].view_callable = (view,) + return view + ########## Model Mixins ########## |
