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. |
| 15 | try: |
| 16 | import_path = '' |
| 17 | backend = __import__('%s%s.base' % (import_path, settings.DATABASE_ENGINE), {}, {}, ['']) |
| 18 | except ImportError, e_user: |
| 19 | # The database backend wasn't found. Display a helpful error message |
| 20 | # listing all possible database backends. |
| 21 | from django.core.exceptions import ImproperlyConfigured |
| 22 | import os |
| 23 | backend_dir = os.path.join(__path__[0], 'backends') |
| 24 | 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')] |
| 25 | available_backends.sort() |
| 26 | if settings.DATABASE_ENGINE not in available_backends: |
| 27 | raise ImproperlyConfigured, "%r isn't an available database backend. Available options are: %s" % \ |
| 28 | (settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends))) |
| 29 | else: |
| 30 | 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() |
| 32 | def get_module_curried(import_path='', module_name=''): |
| 33 | return __import__('%s%s.%s' % (import_path, settings.DATABASE_ENGINE, module_name), {}, {}, ['']) |