当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.AppRegistryNotReady方法代码示例

本文整理汇总了Python中django.core.exceptions.AppRegistryNotReady方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.AppRegistryNotReady方法的具体用法?Python exceptions.AppRegistryNotReady怎么用?Python exceptions.AppRegistryNotReady使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.core.exceptions的用法示例。


在下文中一共展示了exceptions.AppRegistryNotReady方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_installed_apps

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def set_installed_apps(self, installed):
        """
        Enables a different set of installed apps for get_app_config[s].

        installed must be an iterable in the same format as INSTALLED_APPS.

        set_installed_apps() must be balanced with unset_installed_apps(),
        even if it exits with an exception.

        Primarily used as a receiver of the setting_changed signal in tests.

        This method may trigger new imports, which may add new models to the
        registry of all imported models. They will stay in the registry even
        after unset_installed_apps(). Since it isn't possible to replay
        imports safely (eg. that could lead to registering listeners twice),
        models are registered when they're imported and never removed.
        """
        if not self.ready:
            raise AppRegistryNotReady("App registry isn't ready yet.")
        self.stored_app_configs.append(self.app_configs)
        self.app_configs = OrderedDict()
        self.apps_ready = self.models_ready = self.ready = False
        self.clear_cache()
        self.populate(installed) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:26,代码来源:registry.py

示例2: hydrate_models_and_permissions

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def hydrate_models_and_permissions(app_config):
    """
    Setup content types, base permissions and data source
    specific permission groups for use in the admin.
    """
    try:
        create_contenttypes(app_config, interactive=False, verbosity=4)
    except OperationalError as e:
        logger.error("Error creating content-types: %s" % e)

    try:
        create_permissions(app_config, interactive=False, verbosity=4)
    except OperationalError as e:
        logger.error("Error creating permissions: %s" % e)

    try:
        build_permission_groups(app_config.name)
    except (OperationalError, AppRegistryNotReady) as e:
        logger.error("Error creating permission groups: %s" % e)

    try:
        build_tag_permission_group()
    except (OperationalError, AppRegistryNotReady) as e:
        logger.error("Error creating tagging perm group: %s" % e) 
开发者ID:propublica,项目名称:django-collaborative,代码行数:26,代码来源:permissions.py

示例3: _add_installed_apps_translations

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def _add_installed_apps_translations(self):
        """Merges translations from each installed app."""
        try:
            app_configs = reversed(list(apps.get_app_configs()))
        except AppRegistryNotReady:
            raise AppRegistryNotReady(
                "The translation infrastructure cannot be initialized before the "
                "apps registry is ready. Check that you don't make non-lazy "
                "gettext calls at import time.")
        for app_config in app_configs:
            localedir = os.path.join(app_config.path, 'locale')
            translation = self._new_gnu_trans(localedir)
            self.merge(translation) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:15,代码来源:trans_real.py

示例4: check_apps_ready

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def check_apps_ready(self):
        """
        Raises an exception if all apps haven't been imported yet.
        """
        if not self.apps_ready:
            raise AppRegistryNotReady("Apps aren't loaded yet.") 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:8,代码来源:registry.py

示例5: check_models_ready

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def check_models_ready(self):
        """
        Raises an exception if all models haven't been imported yet.
        """
        if not self.models_ready:
            raise AppRegistryNotReady("Models aren't loaded yet.") 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:8,代码来源:registry.py

示例6: check_models_ready

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def check_models_ready(self):
        """
        Raises an exception if models haven't been imported yet.
        """
        if self.models is None:
            raise AppRegistryNotReady(
                "Models for app '%s' haven't been imported yet." % self.label) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:9,代码来源:config.py

示例7: _add_installed_apps_translations

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def _add_installed_apps_translations(self):
        """Merge translations from each installed app."""
        try:
            app_configs = reversed(list(apps.get_app_configs()))
        except AppRegistryNotReady:
            raise AppRegistryNotReady(
                "The translation infrastructure cannot be initialized before the "
                "apps registry is ready. Check that you don't make non-lazy "
                "gettext calls at import time.")
        for app_config in app_configs:
            localedir = os.path.join(app_config.path, 'locale')
            if os.path.exists(localedir):
                translation = self._new_gnu_trans(localedir)
                self.merge(translation) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:16,代码来源:trans_real.py

示例8: _add_installed_apps_translations

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def _add_installed_apps_translations(self):
        """Merges translations from each installed app."""
        try:
            app_configs = reversed(list(apps.get_app_configs()))
        except AppRegistryNotReady:
            raise AppRegistryNotReady(
                "The translation infrastructure cannot be initialized before the "
                "apps registry is ready. Check that you don't make non-lazy "
                "gettext calls at import time.")
        for app_config in app_configs:
            localedir = os.path.join(app_config.path, 'locale')
            if os.path.exists(localedir):
                translation = self._new_gnu_trans(localedir)
                self.merge(translation) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:16,代码来源:trans_real.py

示例9: test_models_not_loaded

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def test_models_not_loaded(self):
        """
        apps.get_models() raises an exception if apps.models_ready isn't True.
        """
        apps.models_ready = False
        try:
            # The cache must be cleared to trigger the exception.
            apps.get_models.cache_clear()
            with self.assertRaisesMessage(AppRegistryNotReady, "Models aren't loaded yet."):
                apps.get_models()
        finally:
            apps.models_ready = True 
开发者ID:nesdis,项目名称:djongo,代码行数:14,代码来源:tests.py

示例10: test_get_containing_app_config_apps_not_ready

# 需要导入模块: from django.core import exceptions [as 别名]
# 或者: from django.core.exceptions import AppRegistryNotReady [as 别名]
def test_get_containing_app_config_apps_not_ready(self):
        """
        apps.get_containing_app_config() should raise an exception if
        apps.apps_ready isn't True.
        """
        apps.apps_ready = False
        try:
            with self.assertRaisesMessage(AppRegistryNotReady, "Apps aren't loaded yet"):
                apps.get_containing_app_config('foo')
        finally:
            apps.apps_ready = True 
开发者ID:nesdis,项目名称:djongo,代码行数:13,代码来源:tests.py


注:本文中的django.core.exceptions.AppRegistryNotReady方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。