Removing hack for python 2.6 support
Python 2.6 support was dropped with the last release, we no longer need this code. Change-Id: I2957864a9a4ae81c6cd2042f226140a5f7af5457
This commit is contained in:
parent
829cbee14e
commit
ab9678d4b4
@ -18,6 +18,7 @@ import logging
|
||||
import pytz
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.module_loading import import_string # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from keystoneclient import exceptions as keystone_exceptions
|
||||
|
||||
@ -47,7 +48,7 @@ class KeystoneBackend(object):
|
||||
['openstack_auth.plugin.password.PasswordPlugin',
|
||||
'openstack_auth.plugin.token.TokenPlugin'])
|
||||
|
||||
self._auth_plugins = [utils.import_string(p)() for p in plugins]
|
||||
self._auth_plugins = [import_string(p)() for p in plugins]
|
||||
|
||||
return self._auth_plugins
|
||||
|
||||
|
@ -14,9 +14,7 @@
|
||||
import datetime
|
||||
import functools
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.contrib import auth
|
||||
from django.contrib.auth import middleware
|
||||
@ -29,7 +27,6 @@ from keystoneclient.auth import token_endpoint
|
||||
from keystoneclient import session
|
||||
from keystoneclient.v2_0 import client as client_v2
|
||||
from keystoneclient.v3 import client as client_v3
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
|
||||
@ -317,65 +314,3 @@ def get_endpoint_region(endpoint):
|
||||
Keystone V2 and V3.
|
||||
"""
|
||||
return endpoint.get('region_id') or endpoint.get('region')
|
||||
|
||||
|
||||
if django.VERSION < (1, 7):
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
# NOTE(jamielennox): importlib was introduced in python 2.7. This is
|
||||
# copied from the backported importlib library. See:
|
||||
# http://svn.python.org/projects/python/trunk/Lib/importlib/__init__.py
|
||||
|
||||
def _resolve_name(name, package, level):
|
||||
"""Return the absolute name of the module to be imported."""
|
||||
if not hasattr(package, 'rindex'):
|
||||
raise ValueError("'package' not set to a string")
|
||||
dot = len(package)
|
||||
for x in xrange(level, 1, -1):
|
||||
try:
|
||||
dot = package.rindex('.', 0, dot)
|
||||
except ValueError:
|
||||
raise ValueError("attempted relative import beyond "
|
||||
"top-level package")
|
||||
return "%s.%s" % (package[:dot], name)
|
||||
|
||||
def import_module(name, package=None):
|
||||
"""Import a module.
|
||||
|
||||
The 'package' argument is required when performing a relative
|
||||
import. It specifies the package to use as the anchor point from
|
||||
which to resolve the relative import to an absolute import.
|
||||
"""
|
||||
if name.startswith('.'):
|
||||
if not package:
|
||||
raise TypeError("relative imports require the "
|
||||
"'package' argument")
|
||||
level = 0
|
||||
for character in name:
|
||||
if character != '.':
|
||||
break
|
||||
level += 1
|
||||
name = _resolve_name(name[level:], package, level)
|
||||
__import__(name)
|
||||
return sys.modules[name]
|
||||
|
||||
# NOTE(jamielennox): copied verbatim from django 1.7
|
||||
def import_string(dotted_path):
|
||||
try:
|
||||
module_path, class_name = dotted_path.rsplit('.', 1)
|
||||
except ValueError:
|
||||
msg = "%s doesn't look like a module path" % dotted_path
|
||||
six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
|
||||
|
||||
module = import_module(module_path)
|
||||
|
||||
try:
|
||||
return getattr(module, class_name)
|
||||
except AttributeError:
|
||||
msg = 'Module "%s" does not define a "%s" attribute/class' % (
|
||||
dotted_path, class_name)
|
||||
six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
|
||||
|
||||
else:
|
||||
from django.utils.module_loading import import_string # noqa
|
||||
|
Loading…
Reference in New Issue
Block a user