當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。