0002-utils-add-import_class-method-refs-5281.patch
authentic2/utils.py | ||
---|---|---|
118 | 118 |
return transform |
119 | 119 | |
120 | 120 |
def import_from(module, name): |
121 |
module = __import__(module, fromlist=[name]) |
|
122 |
return getattr(module, name) |
|
121 |
try: |
|
122 |
module = __import__(module, fromlist=[name]) |
|
123 |
except ImportError, e: |
|
124 |
raise ImproperlyConfigured('Error importing module %s: "%s"' % (module, e)) |
|
125 |
except ValueError, e: |
|
126 |
raise ImproperlyConfigured('Error importing module %r. It does not seem to be a string.' % module) |
|
127 |
try: |
|
128 |
return getattr(module, name) |
|
129 |
except AttributeError: |
|
130 |
raise ImproperlyConfigured('Module "%s" does not define a "%s" class' % (module, name)) |
|
131 | ||
132 |
def import_class(path): |
|
133 |
try: |
|
134 |
module, name = path.rsplit('.') |
|
135 |
except ValueError, e: |
|
136 |
raise ImproperlyConfigured('Class path %s should contain at least a dot: %s' % (path, e)) |
|
137 |
return import_from(module, name) |
|
123 | 138 | |
124 | 139 |
def get_session_store(): |
125 | 140 |
return import_module(settings.SESSION_ENGINE).SessionStore |
126 |
- |