13 | | # The database backend wasn't found. Display a helpful error message |
14 | | # listing all possible database backends. |
15 | | from django.core.exceptions import ImproperlyConfigured |
16 | | import os |
17 | | backend_dir = os.path.join(__path__[0], 'backends') |
18 | | available_backends = [f for f in os.listdir(backend_dir) if not f.startswith('_') and not f.startswith('.') and not f.endswith('.py') and not f.endswith('.pyc')] |
19 | | available_backends.sort() |
20 | | if settings.DATABASE_ENGINE not in available_backends: |
21 | | raise ImproperlyConfigured, "%r isn't an available database backend. Available options are: %s" % \ |
22 | | (settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends))) |
23 | | else: |
24 | | raise # If there's some other error, this must be an error in Django itself. |
| 14 | try: |
| 15 | import_path = '' |
| 16 | backend = __import__('%s%s.base' % (import_path, settings.DATABASE_ENGINE), {}, {}, ['']) |
| 17 | except ImportError, e_user: |
| 18 | # The database backend wasn't found. Display a helpful error message |
| 19 | # listing all possible database backends. |
| 20 | from django.core.exceptions import ImproperlyConfigured |
| 21 | import os |
| 22 | backend_dir = os.path.join(__path__[0], 'backends') |
| 23 | available_backends = [f for f in os.listdir(backend_dir) if not f.startswith('_') and not f.startswith('.') and not f.endswith('.py') and not f.endswith('.pyc')] |
| 24 | available_backends.sort() |
| 25 | if settings.DATABASE_ENGINE not in available_backends: |
| 26 | raise ImproperlyConfigured, "%r isn't an available database backend. Available options are: %s" % \ |
| 27 | (settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends))) |
| 28 | else: |
| 29 | raise # If there's some other error, this must be an error in Django itself. |
26 | | get_introspection_module = lambda: __import__('django.db.backends.%s.introspection' % settings.DATABASE_ENGINE, {}, {}, ['']) |
27 | | get_creation_module = lambda: __import__('django.db.backends.%s.creation' % settings.DATABASE_ENGINE, {}, {}, ['']) |
28 | | runshell = lambda: __import__('django.db.backends.%s.client' % settings.DATABASE_ENGINE, {}, {}, ['']).runshell() |
| 31 | get_introspection_module = lambda: __import__('%s%s.introspection' % (import_path, settings.DATABASE_ENGINE), {}, {}, ['']) |
| 32 | get_creation_module = lambda: __import__('%s%s.creation' % (import_path, settings.DATABASE_ENGINE), {}, {}, ['']) |
| 33 | runshell = lambda: __import__('%s%s.client' % (import_path, settings.DATABASE_ENGINE), {}, {}, ['']).runshell() |