~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to django/contrib/auth/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import datetime
 
2
from warnings import warn
2
3
from django.core.exceptions import ImproperlyConfigured
3
4
from django.utils.importlib import import_module
4
5
 
12
13
    try:
13
14
        mod = import_module(module)
14
15
    except ImportError, e:
15
 
        raise ImproperlyConfigured, 'Error importing authentication backend %s: "%s"' % (module, e)
 
16
        raise ImproperlyConfigured('Error importing authentication backend %s: "%s"' % (module, e))
16
17
    except ValueError, e:
17
 
        raise ImproperlyConfigured, 'Error importing authentication backends. Is AUTHENTICATION_BACKENDS a correctly defined list or tuple?'
 
18
        raise ImproperlyConfigured('Error importing authentication backends. Is AUTHENTICATION_BACKENDS a correctly defined list or tuple?')
18
19
    try:
19
20
        cls = getattr(mod, attr)
20
21
    except AttributeError:
21
 
        raise ImproperlyConfigured, 'Module "%s" does not define a "%s" authentication backend' % (module, attr)
 
22
        raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
 
23
    try:
 
24
        getattr(cls, 'supports_object_permissions')
 
25
    except AttributeError:
 
26
        warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
 
27
             PendingDeprecationWarning)
 
28
        cls.supports_object_permissions = False
 
29
    try:
 
30
        getattr(cls, 'supports_anonymous_user')
 
31
    except AttributeError:
 
32
        warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
 
33
             PendingDeprecationWarning)
 
34
        cls.supports_anonymous_user = False
22
35
    return cls()
23
36
 
24
37
def get_backends():