Python django.conf.settings 模块,DATABASE_ROUTERS 实例源码

我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用django.conf.settings.DATABASE_ROUTERS

项目:django-autoshard    作者:cipriantarta    | 项目源码 | 文件源码
def configure(self):
        shards = dict()
        nodes = django_settings.DJANGO_AUTOSHARD.NODES
        for node in nodes:
            try:
                _ = node['HOST']
            except KeyError:
                raise exceptions.ImproperlyConfigured('Node {} does not have a host.'.format(node))
            try:
                _ = node['RANGE']
            except KeyError:
                raise exceptions.ImproperlyConfigured('Node {} does not specify a shard range.'.format(node))

            node_shards = self.set_logical_shards(node)
            shards.update(node_shards)

        django_settings.SHARDS = OrderedDict(sorted(shards.items()))
        django_settings.DATABASE_ROUTERS = ('django_autoshard.routers.ShardRouter', )
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers