diff options
| author | Sébastien Piquemal | 2012-02-02 18:19:44 +0200 |
|---|---|---|
| committer | Sébastien Piquemal | 2012-02-02 18:19:44 +0200 |
| commit | 5bb6301b7f53e3815ab1a81a5fa38721dc95b113 (patch) | |
| tree | 27d53698a374ac62c4a3be41b23173775c92f207 /djangorestframework/permissions.py | |
| parent | 5f59d90645dfddc293bbbbc4ca9b4c3f3125b590 (diff) | |
| download | django-rest-framework-5bb6301b7f53e3815ab1a81a5fa38721dc95b113.tar.bz2 | |
Response as a subclass of HttpResponse - first draft, not quite there yet.
Diffstat (limited to 'djangorestframework/permissions.py')
| -rw-r--r-- | djangorestframework/permissions.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/djangorestframework/permissions.py b/djangorestframework/permissions.py index dfe55ce9..bce03cab 100644 --- a/djangorestframework/permissions.py +++ b/djangorestframework/permissions.py @@ -22,13 +22,13 @@ __all__ = ( _403_FORBIDDEN_RESPONSE = ErrorResponse( - status.HTTP_403_FORBIDDEN, - {'detail': 'You do not have permission to access this resource. ' + - 'You may need to login or otherwise authenticate the request.'}) + content={'detail': 'You do not have permission to access this resource. ' + + 'You may need to login or otherwise authenticate the request.'}, + status=status.HTTP_403_FORBIDDEN) _503_SERVICE_UNAVAILABLE = ErrorResponse( - status.HTTP_503_SERVICE_UNAVAILABLE, - {'detail': 'request was throttled'}) + content={'detail': 'request was throttled'}, + status=status.HTTP_503_SERVICE_UNAVAILABLE) class BasePermission(object): @@ -152,7 +152,7 @@ class BaseThrottle(BasePermission): self.history.insert(0, self.now) cache.set(self.key, self.history, self.duration) header = 'status=SUCCESS; next=%s sec' % self.next() - self.view.add_header('X-Throttle', header) + self.view.headers['X-Throttle'] = header def throttle_failure(self): """ @@ -160,7 +160,7 @@ class BaseThrottle(BasePermission): Raises a '503 service unavailable' response. """ header = 'status=FAILURE; next=%s sec' % self.next() - self.view.add_header('X-Throttle', header) + self.view.headers['X-Throttle'] = header raise _503_SERVICE_UNAVAILABLE def next(self): |
