Ticket #18575: 18575-3.diff

File 18575-3.diff, 1.6 KB (added by Claude Paroz, 12 years ago)

Allow setting DATABASES to empty dict (will default to dummy engine)

  • django/conf/global_settings.py

    diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
    index f1cbb22..2f1d48f 100644
    a b SERVER_EMAIL = 'root@localhost'  
    151151SEND_BROKEN_LINK_EMAILS = False
    152152
    153153# Database connection info.
    154 DATABASES = {
    155     'default': {
    156         'ENGINE': 'django.db.backends.dummy',
    157     },
    158 }
     154DATABASES = {}
    159155
    160156# Classes used to implement DB routing behavior.
    161157DATABASE_ROUTERS = []
  • django/db/__init__.py

    diff --git a/django/db/__init__.py b/django/db/__init__.py
    index 26c7add..b198048 100644
    a b __all__ = ('backend', 'connection', 'connections', 'router', 'DatabaseError',  
    88    'IntegrityError', 'DEFAULT_DB_ALIAS')
    99
    1010
    11 if DEFAULT_DB_ALIAS not in settings.DATABASES:
     11if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
    1212    raise ImproperlyConfigured("You must define a '%s' database" % DEFAULT_DB_ALIAS)
    1313
    1414connections = ConnectionHandler(settings.DATABASES)
  • django/db/utils.py

    diff --git a/django/db/utils.py b/django/db/utils.py
    index 5fa78fe..a912986 100644
    a b class ConnectionDoesNotExist(Exception):  
    5353
    5454class ConnectionHandler(object):
    5555    def __init__(self, databases):
    56         self.databases = databases
     56        if not databases:
     57            self.databases = {
     58                DEFAULT_DB_ALIAS: {
     59                    'ENGINE': 'django.db.backends.dummy',
     60                },
     61            }
     62        else:
     63            self.databases = databases
    5764        self._connections = local()
    5865
    5966    def ensure_defaults(self, alias):
Back to Top