summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-08-28 08:21:30 +0000
committerGerrit Code Review <review@openstack.org>2015-08-28 08:21:30 +0000
commit3c833372a73c82516e8bfd05513f47d80043f65e (patch)
treeecbbe1b29eeea49a3ab3c7fd16d261f91ee99624
parentb5e591763d712341639513bd8d1112a13974a529 (diff)
parentab9678d4b447d757446175e85fd27185fa5831f1 (diff)
downloaddjango_openstack_auth-3c833372a73c82516e8bfd05513f47d80043f65e.tar.gz
Merge "Removing hack for python 2.6 support"
-rw-r--r--openstack_auth/backend.py3
-rw-r--r--openstack_auth/utils.py65
2 files changed, 2 insertions, 66 deletions
diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py
index 0e277cf..c630fb0 100644
--- a/openstack_auth/backend.py
+++ b/openstack_auth/backend.py
@@ -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
diff --git a/openstack_auth/utils.py b/openstack_auth/utils.py
index c13a84b..1998bcf 100644
--- a/openstack_auth/utils.py
+++ b/openstack_auth/utils.py
@@ -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