示例#1
0
def setup():
    """
    Configure Django enough to use the ORM.
    """
    cfg = config.parser(section='web_portal')
    # INSTALLED_APPS doesn't seem necessary so long as you are only accessing
    # existing tables.
    #
    # Setting charset to latin1 is a disgusting kludge, but without
    # this MySQL 5.6 (and, proably, later) gets tetchy about ASN.1 DER
    # stored in BLOB columns not being well-formed UTF8 (sic).  If you
    # know of a better solution, tell us.
    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.mysql',
                'NAME': cfg.get('sql-database'),
                'USER': cfg.get('sql-username'),
                'PASSWORD': cfg.get('sql-password'),
                'OPTIONS': {
                    'charset': 'latin1',
                }
            }
        },
        MIDDLEWARE_CLASSES=(),
        DOWNLOAD_DIRECTORY=cfg.get('download-directory', '/var/tmp'),
    )
    if django.VERSION >= (1, 7):
        from django.apps import apps
        apps.populate(settings.INSTALLED_APPS)
def setup():
    """
    Configure Django enough to use the ORM.
    """
    cfg = config.parser(section='web_portal')
    # INSTALLED_APPS doesn't seem necessary so long as you are only accessing
    # existing tables.
    #
    # Setting charset to latin1 is a disgusting kludge, but without
    # this MySQL 5.6 (and, proably, later) gets tetchy about ASN.1 DER
    # stored in BLOB columns not being well-formed UTF8 (sic).  If you
    # know of a better solution, tell us.
    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.mysql',
                'NAME': cfg.get('sql-database'),
                'USER': cfg.get('sql-username'),
                'PASSWORD': cfg.get('sql-password'),
                'OPTIONS': {
                    'charset': 'latin1',
                    }
            }
        },
        MIDDLEWARE_CLASSES = (),
        DOWNLOAD_DIRECTORY = cfg.get('download-directory', '/var/tmp'),
    )
    if django.VERSION >= (1, 7):
        from django.apps import apps
        apps.populate(settings.INSTALLED_APPS)
示例#3
0
def setup():
    """
    Configure Django enough to use the ORM.
    """
    cfg = config.parser(section='web_portal')
    # INSTALLED_APPS doesn't seem necessary so long as you are only accessing
    # existing tables.
    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.mysql',
                'NAME': cfg.get('sql-database'),
                'USER': cfg.get('sql-username'),
                'PASSWORD': cfg.get('sql-password'),
            }
        },
        MIDDLEWARE_CLASSES=(),
        DOWNLOAD_DIRECTORY=cfg.get('download-directory', '/var/tmp'),
    )
    if django.VERSION >= (1, 7):
        from django.apps import apps
        apps.populate(settings.INSTALLED_APPS)
示例#4
0
def setup():
    """
    Configure Django enough to use the ORM.
    """
    cfg = config.parser(section='web_portal')
    # INSTALLED_APPS doesn't seem necessary so long as you are only accessing
    # existing tables.
    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.mysql',
                'NAME': cfg.get('sql-database'),
                'USER': cfg.get('sql-username'),
                'PASSWORD': cfg.get('sql-password'),
            }
        },
        MIDDLEWARE_CLASSES = (),
        DOWNLOAD_DIRECTORY = cfg.get('download-directory', '/var/tmp'),
    )
    if django.VERSION >= (1, 7):
        from django.apps import apps
        apps.populate(settings.INSTALLED_APPS)