Ticket #8193: import_fixes_8272.diff
File import_fixes_8272.diff, 15.1 KB (added by , 16 years ago) |
---|
-
django/test/client.py
170 170 Obtains the current session variables. 171 171 """ 172 172 if 'django.contrib.sessions' in settings.INSTALLED_APPS: 173 engine = __import__(settings.SESSION_ENGINE, {}, {}, [ ''])173 engine = __import__(settings.SESSION_ENGINE, {}, {}, [settings.SESSION_ENGINE.split('.')[-1]]) 174 174 cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) 175 175 if cookie: 176 176 return engine.SessionStore(cookie.value) … … 295 295 user = authenticate(**credentials) 296 296 if user and user.is_active \ 297 297 and 'django.contrib.sessions' in settings.INSTALLED_APPS: 298 engine = __import__(settings.SESSION_ENGINE, {}, {}, [ ''])298 engine = __import__(settings.SESSION_ENGINE, {}, {}, [settings.SESSION_ENGINE.split('.')[-1]]) 299 299 300 300 # Create a fake request to store login details. 301 301 request = HttpRequest() … … 327 327 328 328 Causes the authenticated user to be logged out. 329 329 """ 330 session = __import__(settings.SESSION_ENGINE, {}, {}, [ '']).SessionStore()330 session = __import__(settings.SESSION_ENGINE, {}, {}, [settings.SESSION_ENGINE.split('.')[-1]]).SessionStore() 331 331 session.delete(session_key=self.cookies[settings.SESSION_COOKIE_NAME].value) 332 332 self.cookies = SimpleCookie() -
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), {}, {}, [' '])17 creation = __import__('%s%s.creation' % (_import_path, settings.DATABASE_ENGINE), {}, {}, [' '])16 backend = __import__('%s%s.base' % (_import_path, settings.DATABASE_ENGINE), {}, {}, ['base']) 17 creation = __import__('%s%s.creation' % (_import_path, settings.DATABASE_ENGINE), {}, {}, ['creation']) 18 18 except ImportError, e: 19 19 # If the import failed, we might be looking for a database backend 20 20 # distributed external to Django. So we'll try that next. 21 21 try: 22 22 _import_path = '' 23 backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, [' '])24 creation = __import__('%s.creation' % settings.DATABASE_ENGINE, {}, {}, [' '])23 backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, ['base']) 24 creation = __import__('%s.creation' % settings.DATABASE_ENGINE, {}, {}, ['creation']) 25 25 except ImportError, e_user: 26 26 # The database backend wasn't found. Display a helpful error message 27 27 # listing all possible (built-in) database backends. -
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 for d in os.listdir(appdir): 114 114 if d.isalpha() and os.path.isdir(os.path.join(appdir, d)): 115 115 new_installed_apps.append('%s.%s' % (app[:-2], d)) -
django/core/serializers/__init__.py
36 36 37 37 def register_serializer(format, serializer_module): 38 38 """Register a new serializer by passing in a module name.""" 39 module = __import__(serializer_module, {}, {}, [ ''])39 module = __import__(serializer_module, {}, {}, [serializer_module.split('.')[-1]]) 40 40 _serializers[format] = module 41 41 42 42 def unregister_serializer(format): -
django/core/urlresolvers.py
51 51 lookup_view = lookup_view.encode('ascii') 52 52 mod_name, func_name = get_mod_func(lookup_view) 53 53 if func_name != '': 54 lookup_view = getattr(__import__(mod_name, {}, {}, [ '']), func_name)54 lookup_view = getattr(__import__(mod_name, {}, {}, [mod_name.split('.')[-1]]), func_name) 55 55 except (ImportError, AttributeError): 56 56 if not can_fail: 57 57 raise … … 195 195 def reverse(self, viewname, *args, **kwargs): 196 196 mod_name, func_name = get_mod_func(viewname) 197 197 try: 198 lookup_view = getattr(__import__(mod_name, {}, {}, [ '']), func_name)198 lookup_view = getattr(__import__(mod_name, {}, {}, [mod_name.split('.')[-1]]), func_name) 199 199 except (ImportError, AttributeError): 200 200 raise NoReverseMatch 201 201 if lookup_view != self.callback: … … 255 255 return self._urlconf_module 256 256 except AttributeError: 257 257 try: 258 self._urlconf_module = __import__(self.urlconf_name, {}, {}, [ ''])258 self._urlconf_module = __import__(self.urlconf_name, {}, {}, [self.urlconf_name.split('.')[-1]]) 259 259 except Exception, e: 260 260 # Either an invalid urlconf_name, such as "foo.bar.", or some 261 261 # kind of problem during the actual import. … … 271 271 callback = getattr(self.urlconf_module, 'handler%s' % view_type) 272 272 mod_name, func_name = get_mod_func(callback) 273 273 try: 274 return getattr(__import__(mod_name, {}, {}, [ '']), func_name), {}274 return getattr(__import__(mod_name, {}, {}, [mod_name.split('.')[-1]]), func_name), {} 275 275 except (ImportError, AttributeError), e: 276 276 raise ViewDoesNotExist, "Tried %s. Error was: %s" % (callback, str(e)) 277 277 -
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
203 203 raise ImproperlyConfigured("%s isn't a storage module." % import_path) 204 204 module, classname = import_path[:dot], import_path[dot+1:] 205 205 try: 206 mod = __import__(module, {}, {}, [ ''])206 mod = __import__(module, {}, {}, [module.split('.')[-1]]) 207 207 except ImportError, e: 208 208 raise ImproperlyConfigured('Error importing storage module %s: "%s"' % (module, e)) 209 209 try: -
django/core/cache/__init__.py
48 48 host = host[:-1] 49 49 50 50 if scheme in BACKENDS: 51 module = __import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, [ ''])51 module = __import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, [BACKENDS[scheme]]) 52 52 else: 53 module = __import__(scheme, {}, {}, [ ''])53 module = __import__(scheme, {}, {}, [scheme.split('.')[-1]]) 54 54 return getattr(module, 'CacheClass')(host, params) 55 55 56 56 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
308 308 project_name = os.path.basename(project_directory) 309 309 settings_name = os.path.splitext(settings_filename)[0] 310 310 sys.path.append(os.path.join(project_directory, os.pardir)) 311 project_module = __import__(project_name, {}, {}, [ ''])311 project_module = __import__(project_name, {}, {}, [project_name.split('.')[-1]]) 312 312 sys.path.pop() 313 313 314 314 # 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/admin/views/template.py
14 14 # get a dict of {site_id : settings_module} for the validator 15 15 settings_modules = {} 16 16 for mod in settings.ADMIN_FOR: 17 settings_module = __import__(mod, {}, {}, [ ''])17 settings_module = __import__(mod, {}, {}, [mod.split('.')[-1]]) 18 18 settings_modules[settings_module.SITE_ID] = settings_module 19 19 manipulator = TemplateValidator(settings_modules) 20 20 new_data, errors = {}, {} -
django/contrib/admindocs/views.py
112 112 return missing_docutils_page(request) 113 113 114 114 if settings.ADMIN_FOR: 115 settings_modules = [__import__(m, {}, {}, [ '']) for m in settings.ADMIN_FOR]115 settings_modules = [__import__(m, {}, {}, [m.split('.')[-1]]) for m in settings.ADMIN_FOR] 116 116 else: 117 117 settings_modules = [settings] 118 118 119 119 views = [] 120 120 for settings_mod in settings_modules: 121 urlconf = __import__(settings_mod.ROOT_URLCONF, {}, {}, [ ''])121 urlconf = __import__(settings_mod.ROOT_URLCONF, {}, {}, [settings_mod.ROOT_URLCONF.split('.')[-1]]) 122 122 view_functions = extract_views_from_urlpatterns(urlconf.urlpatterns) 123 123 if Site._meta.installed: 124 124 site_obj = Site.objects.get(pk=settings_mod.SITE_ID) … … 145 145 146 146 mod, func = urlresolvers.get_mod_func(view) 147 147 try: 148 view_func = getattr(__import__(mod, {}, {}, [ '']), func)148 view_func = getattr(__import__(mod, {}, {}, [mod.split('.')[-1]]), func) 149 149 except (ImportError, AttributeError): 150 150 raise Http404 151 151 title, body, metadata = utils.parse_docstring(view_func.__doc__) … … 259 259 def template_detail(request, template): 260 260 templates = [] 261 261 for site_settings_module in settings.ADMIN_FOR: 262 settings_mod = __import__(site_settings_module, {}, {}, [ ''])262 settings_mod = __import__(site_settings_module, {}, {}, [site_settings_module.split('.')[-1]]) 263 263 if Site._meta.installed: 264 264 site_obj = Site.objects.get(pk=settings_mod.SITE_ID) 265 265 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
917 917 lib = libraries.get(module_name, None) 918 918 if not lib: 919 919 try: 920 mod = __import__(module_name, {}, {}, [ ''])920 mod = __import__(module_name, {}, {}, [module_name.split('.')[-1]]) 921 921 except ImportError, e: 922 922 raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e)) 923 923 try: