diff options
| author | Tom Christie | 2012-09-06 15:42:54 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-09-06 15:42:54 +0100 |
| commit | 74c50b953557ea283a6cd601ad3656379369eb47 (patch) | |
| tree | 1e057d83a4ea76d2cc176d2485a1d99881d05edc /djangorestframework/request.py | |
| parent | b7062c5b01fbcd1fecb9ad2cd9a73eba77bd7632 (diff) | |
| download | django-rest-framework-74c50b953557ea283a6cd601ad3656379369eb47.tar.bz2 | |
Settings suppport importpaths
Diffstat (limited to 'djangorestframework/request.py')
| -rw-r--r-- | djangorestframework/request.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/djangorestframework/request.py b/djangorestframework/request.py index cddb1415..6c00ff62 100644 --- a/djangorestframework/request.py +++ b/djangorestframework/request.py @@ -11,9 +11,8 @@ The wrapped request then offers a richer API, in particular : """ from StringIO import StringIO -from django.contrib.auth.models import AnonymousUser - from djangorestframework import exceptions +from djangorestframework.settings import api_settings from djangorestframework.utils.mediatypes import is_form_media_type @@ -251,10 +250,26 @@ class Request(object): return self._not_authenticated() def _not_authenticated(self): - return (AnonymousUser(), None) + """ + Return a two-tuple of (user, authtoken), representing an + unauthenticated request. + + By default this will be (AnonymousUser, None). + """ + if api_settings.UNAUTHENTICATED_USER: + user = api_settings.UNAUTHENTICATED_USER() + else: + user = None + + if api_settings.UNAUTHENTICATED_TOKEN: + auth = api_settings.UNAUTHENTICATED_TOKEN() + else: + auth = None + + return (user, auth) - def __getattr__(self, name): + def __getattr__(self, attr): """ Proxy other attributes to the underlying HttpRequest object. """ - return getattr(self._request, name) + return getattr(self._request, attr) |
