コード例 #1
0
ファイル: db.py プロジェクト: olivier-m/django-appschema
# -*- coding: utf-8 -*-
#
# This file is part of Django appschema released under the MIT license.
# See the LICENSE for more information.
from multiprocessing import Process

from django import db

import appschema
syncdb = appschema.syncdb()
migrate = appschema.migrate()

from appschema.schema import schema_store
from appschema.utils import get_apps, load_post_syncdb_signals, run_with_apps


def _syncdb_apps(apps, schema=None, force_close=True, **options):
    """
    This function simply call syncdb command (Django or South one) for
    select apps only.
    """
    def wrapper(_apps, *args, **kwargs):
        load_post_syncdb_signals()
        return syncdb.Command().execute(**kwargs)

    # Force connection close
    if force_close:
        db.connection.close()
        db.connection.connection = None

    # Force default DB if not specified
コード例 #2
0
ファイル: db.py プロジェクト: edwinwow/django-appschema
# -*- coding: utf-8 -*-
#
# This file is part of Django appschema released under the MIT license.
# See the LICENSE for more information.

from django import db

from appschema import syncdb, migrate
syncdb = syncdb()
migrate = migrate()

from appschema.schema import schema_store
from appschema.utils import get_apps, load_post_syncdb_signals, run_with_apps

def syncdb_apps(apps, schema=None, **options):
    """
    This function simply call syncdb command (Django or South one) for
    select apps only.
    """
    def wrapper(_apps, *args, **kwargs):
        load_post_syncdb_signals()
        return syncdb.Command().execute(**kwargs)
    
    # Syncdb without schema (on public)
    if not schema:
        schema_store.reset_path()
        return run_with_apps(apps, wrapper, **options)
    
    # Syncdb with schema
    #
    # We first handle the case of apps that are both shared and isolated.