Ticket #8193: import_fixes.5.diff
File import_fixes.5.diff, 16.2 KB (added by , 16 years ago) |
---|
-
django/test/client.py
171 171 Obtains the current session variables. 172 172 """ 173 173 if 'django.contrib.sessions' in settings.INSTALLED_APPS: 174 engine = __import__(settings.SESSION_ENGINE, {}, {}, [ ''])174 engine = __import__(settings.SESSION_ENGINE, {}, {}, [settings.SESSION_ENGINE.split('.')[-1]]) 175 175 cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) 176 176 if cookie: 177 177 return engine.SessionStore(cookie.value) … … 302 302 user = authenticate(**credentials) 303 303 if user and user.is_active \ 304 304 and 'django.contrib.sessions' in settings.INSTALLED_APPS: 305 engine = __import__(settings.SESSION_ENGINE, {}, {}, [ ''])305 engine = __import__(settings.SESSION_ENGINE, {}, {}, [settings.SESSION_ENGINE.split('.')[-1]]) 306 306 307 307 # Create a fake request to store login details. 308 308 request = HttpRequest() … … 337 337 338 338 Causes the authenticated user to be logged out. 339 339 """ 340 session = __import__(settings.SESSION_ENGINE, {}, {}, [ '']).SessionStore()340 session = __import__(settings.SESSION_ENGINE, {}, {}, [settings.SESSION_ENGINE.split('.')[-1]]).SessionStore() 341 341 session.delete(session_key=self.cookies[settings.SESSION_COOKIE_NAME].value) 342 342 self.cookies = SimpleCookie() -
django/conf/__init__.py
89 89 self.SETTINGS_MODULE = settings_module 90 90 91 91 try: 92 mod = __import__(self.SETTINGS_MODULE, {}, {}, [ ''])92 mod = __import__(self.SETTINGS_MODULE, {}, {}, [self.SETTINGS_MODULE.split('.')[-1]]) 93 93 except ImportError, e: 94 94 raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) 95 95 … … 109 109 new_installed_apps = [] 110 110 for app in self.INSTALLED_APPS: 111 111 if app.endswith('.*'): 112 appdir = os.path.dirname(__import__(app[:-2], {}, {}, [ '']).__file__)112 appdir = os.path.dirname(__import__(app[:-2], {}, {}, [app[:-2].split('.')[-1]]).__file__) 113 113 app_subdirs = os.listdir(appdir) 114 114 app_subdirs.sort() 115 115 for d in app_subdirs: -
django/db/__init__.py
13 13 # Most of the time, the database backend will be one of the official 14 14 # backends that ships with Django, so look there first. 15 15 _import_path = 'django.db.backends.' 16 backend = __import__('%s%s.base' % (_import_path, settings.DATABASE_ENGINE), {}, {}, [' '])16 backend = __import__('%s%s.base' % (_import_path, settings.DATABASE_ENGINE), {}, {}, ['base']) 17 17 except ImportError, e: 18 18 # If the import failed, we might be looking for a database backend 19 19 # distributed external to Django. So we'll try that next. 20 20 try: 21 21 _import_path = '' 22 backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, [' '])22 backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, ['base']) 23 23 except ImportError, e_user: 24 24 # The database backend wasn't found. Display a helpful error message 25 25 # listing all possible (built-in) database backends. -
django/core/servers/fastcgi.py
128 128 wsgi_opts['debug'] = False # Turn off flup tracebacks 129 129 130 130 try: 131 WSGIServer = getattr(__import__('flup.' + flup_module, '', '', flup_module), 'WSGIServer')131 WSGIServer = getattr(__import__('flup.' + flup_module, '', '', [flup_module]), 'WSGIServer') 132 132 except: 133 133 print "Can't import flup." + flup_module 134 134 return False -
django/core/serializers/__init__.py
47 47 directly into the global register of serializers. Adding serializers 48 48 directly is not a thread-safe operation. 49 49 """ 50 module = __import__(serializer_module, {}, {}, [ ''])50 module = __import__(serializer_module, {}, {}, [serializer_module.split('.')[-1]]) 51 51 if serializers is None: 52 52 _serializers[format] = module 53 53 else: -
django/core/urlresolvers.py
54 54 lookup_view = lookup_view.encode('ascii') 55 55 mod_name, func_name = get_mod_func(lookup_view) 56 56 if func_name != '': 57 lookup_view = getattr(__import__(mod_name, {}, {}, [ '']), func_name)57 lookup_view = getattr(__import__(mod_name, {}, {}, [mod_name.split('.')[-1]]), func_name) 58 58 if not callable(lookup_view): 59 59 raise AttributeError("'%s.%s' is not a callable." % (mod_name, func_name)) 60 60 except (ImportError, AttributeError): … … 195 195 try: 196 196 return self._urlconf_module 197 197 except AttributeError: 198 self._urlconf_module = __import__(self.urlconf_name, {}, {}, [ ''])198 self._urlconf_module = __import__(self.urlconf_name, {}, {}, [self.urlconf_name.split('.')[-1]]) 199 199 return self._urlconf_module 200 200 urlconf_module = property(_get_urlconf_module) 201 201 … … 207 207 callback = getattr(self.urlconf_module, 'handler%s' % view_type) 208 208 mod_name, func_name = get_mod_func(callback) 209 209 try: 210 return getattr(__import__(mod_name, {}, {}, [ '']), func_name), {}210 return getattr(__import__(mod_name, {}, {}, [mod_name.split('.')[-1]]), func_name), {} 211 211 except (ImportError, AttributeError), e: 212 212 raise ViewDoesNotExist, "Tried %s. Error was: %s" % (callback, str(e)) 213 213 -
django/core/handlers/base.py
35 35 raise exceptions.ImproperlyConfigured, '%s isn\'t a middleware module' % middleware_path 36 36 mw_module, mw_classname = middleware_path[:dot], middleware_path[dot+1:] 37 37 try: 38 mod = __import__(mw_module, {}, {}, [ ''])38 mod = __import__(mw_module, {}, {}, [mw_module.split('.')[-1]]) 39 39 except ImportError, e: 40 40 raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e) 41 41 try: -
django/core/files/storage.py
219 219 raise ImproperlyConfigured("%s isn't a storage module." % import_path) 220 220 module, classname = import_path[:dot], import_path[dot+1:] 221 221 try: 222 mod = __import__(module, {}, {}, [ ''])222 mod = __import__(module, {}, {}, [module.split('.')[-1]]) 223 223 except ImportError, e: 224 224 raise ImproperlyConfigured('Error importing storage module %s: "%s"' % (module, e)) 225 225 try: -
django/core/cache/__init__.py
49 49 host = host[:-1] 50 50 51 51 if scheme in BACKENDS: 52 module = __import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, [ ''])52 module = __import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, [BACKENDS[scheme]]) 53 53 else: 54 module = __import__(scheme, {}, {}, [ ''])54 module = __import__(scheme, {}, {}, [scheme.split('.')[-1]]) 55 55 return getattr(module, 'CacheClass')(host, params) 56 56 57 57 cache = get_cache(settings.CACHE_BACKEND) -
django/core/management/commands/flush.py
26 26 # dispatcher events. 27 27 for app_name in settings.INSTALLED_APPS: 28 28 try: 29 __import__(app_name + '.management', {}, {}, [' '])29 __import__(app_name + '.management', {}, {}, ['management']) 30 30 except ImportError: 31 31 pass 32 32 -
django/core/management/commands/syncdb.py
33 33 # dispatcher events. 34 34 for app_name in settings.INSTALLED_APPS: 35 35 try: 36 __import__(app_name + '.management', {}, {}, [' '])36 __import__(app_name + '.management', {}, {}, ['management']) 37 37 except ImportError, exc: 38 38 # This is slightly hackish. We want to ignore ImportErrors 39 39 # if the "management" module itself is missing -- but we don't -
django/core/management/__init__.py
313 313 project_name = os.path.basename(project_directory) 314 314 settings_name = os.path.splitext(settings_filename)[0] 315 315 sys.path.append(os.path.join(project_directory, os.pardir)) 316 project_module = __import__(project_name, {}, {}, [ ''])316 project_module = __import__(project_name, {}, {}, [project_name.split('.')[-1]]) 317 317 sys.path.pop() 318 318 319 319 # Set DJANGO_SETTINGS_MODULE appropriately. -
django/templatetags/__init__.py
2 2 3 3 for a in settings.INSTALLED_APPS: 4 4 try: 5 __path__.extend(__import__(a + '.templatetags', {}, {}, [' ']).__path__)5 __path__.extend(__import__(a + '.templatetags', {}, {}, ['templatetags']).__path__) 6 6 except ImportError: 7 7 pass -
django/views/i18n.py
128 128 paths = [] 129 129 # first load all english languages files for defaults 130 130 for package in packages: 131 p = __import__(package, {}, {}, [ ''])131 p = __import__(package, {}, {}, [package.split('.')[-1]]) 132 132 path = os.path.join(os.path.dirname(p.__file__), 'locale') 133 133 paths.append(path) 134 134 try: -
django/contrib/comments/__init__.py
17 17 18 18 # Try to import the package 19 19 try: 20 package = __import__(comments_app, '', '', [''])20 package = __import__(comments_app, {}, {}, [comments_app.split('.')[-1]]) 21 21 except ImportError: 22 22 raise ImproperlyConfigured("The COMMENTS_APP setting refers to "\ 23 23 "a non-existing package.") -
django/contrib/admin/views/template.py
15 15 # get a dict of {site_id : settings_module} for the validator 16 16 settings_modules = {} 17 17 for mod in settings.ADMIN_FOR: 18 settings_module = __import__(mod, {}, {}, [ ''])18 settings_module = __import__(mod, {}, {}, [mod.split('.')[-1]]) 19 19 settings_modules[settings_module.SITE_ID] = settings_module 20 20 site_list = Site.objects.in_bulk(settings_modules.keys()).values() 21 21 if request.POST: -
django/contrib/admindocs/views.py
114 114 return missing_docutils_page(request) 115 115 116 116 if settings.ADMIN_FOR: 117 settings_modules = [__import__(m, {}, {}, [ '']) for m in settings.ADMIN_FOR]117 settings_modules = [__import__(m, {}, {}, [m.split('.')[-1]]) for m in settings.ADMIN_FOR] 118 118 else: 119 119 settings_modules = [settings] 120 120 121 121 views = [] 122 122 for settings_mod in settings_modules: 123 urlconf = __import__(settings_mod.ROOT_URLCONF, {}, {}, [ ''])123 urlconf = __import__(settings_mod.ROOT_URLCONF, {}, {}, [settings_mod.ROOT_URLCONF.split('.')[-1]]) 124 124 view_functions = extract_views_from_urlpatterns(urlconf.urlpatterns) 125 125 if Site._meta.installed: 126 126 site_obj = Site.objects.get(pk=settings_mod.SITE_ID) … … 146 146 147 147 mod, func = urlresolvers.get_mod_func(view) 148 148 try: 149 view_func = getattr(__import__(mod, {}, {}, [ '']), func)149 view_func = getattr(__import__(mod, {}, {}, [mod.split('.')[-1]]), func) 150 150 except (ImportError, AttributeError): 151 151 raise Http404 152 152 title, body, metadata = utils.parse_docstring(view_func.__doc__) … … 257 257 def template_detail(request, template): 258 258 templates = [] 259 259 for site_settings_module in settings.ADMIN_FOR: 260 settings_mod = __import__(site_settings_module, {}, {}, [ ''])260 settings_mod = __import__(site_settings_module, {}, {}, [site_settings_module.split('.')[-1]]) 261 261 if Site._meta.installed: 262 262 site_obj = Site.objects.get(pk=settings_mod.SITE_ID) 263 263 else: -
django/contrib/sessions/middleware.py
6 6 7 7 class SessionMiddleware(object): 8 8 def process_request(self, request): 9 engine = __import__(settings.SESSION_ENGINE, {}, {}, [ ''])9 engine = __import__(settings.SESSION_ENGINE, {}, {}, [settings.SESSION_ENGINE.split('.')[-1]]) 10 10 session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None) 11 11 request.session = engine.SessionStore(session_key) 12 12 -
django/template/__init__.py
934 934 lib = libraries.get(module_name, None) 935 935 if not lib: 936 936 try: 937 mod = __import__(module_name, {}, {}, [ ''])937 mod = __import__(module_name, {}, {}, [module_name.split('.')[-1]]) 938 938 except ImportError, e: 939 939 raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e)) 940 940 try: -
tests/regressiontests/dynamic_imports/tests.py
Property changes on: tests/regressiontests/dynamic_imports ___________________________________________________________________ Added: svn:ignore + *.pyc
1 __test__ = {'API_TESTS': """ 2 >>> import sys 3 >>> import os 4 >>> mod_name = os.environ['DJANGO_SETTINGS_MODULE'] 5 >>> mod = __import__(mod_name, {}, {}, [mod_name.split('.')[-1]]) 6 >>> from django.core.management import setup_environ 7 >>> d = setup_environ(mod) 8 >>> [k for k in sys.modules if k.endswith('.') or '..' in k] 9 [] 10 """}