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


Python app_base.CMSApp方法代码示例

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


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

示例1: register

# 需要导入模块: from cms import app_base [as 别名]
# 或者: from cms.app_base import CMSApp [as 别名]
def register(self, app=None, discovering_apps=False):
        # allow use as a decorator
        if app is None:
            return lambda app: self.register(app, discovering_apps)

        if app.__module__.split('.')[-1] == 'cms_app':
            warnings.warn('cms_app.py filename is deprecated, '
                          'and it will be removed in version 3.4; '
                          'please rename it to cms_apps.py', DeprecationWarning)

        if self.apphooks and not discovering_apps:
            return app

        if app.__name__ in self.apps:
            raise AppAlreadyRegistered(
                'A CMS application %r is already registered' % app.__name__)

        if not issubclass(app, CMSApp):
            raise ImproperlyConfigured(
                'CMS application must inherit from cms.app_base.CMSApp, '
                'but %r does not' % app.__name__)

        if not hasattr(app, 'menus') and hasattr(app, 'menu'):
            warnings.warn("You define a 'menu' attribute on CMS application "
                "%r, but the 'menus' attribute is empty, "
                "did you make a typo?" % app.__name__)

        self.apps[app.__name__] = app()
        return app 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:31,代码来源:apphook_pool.py

示例2: test_apphook_pool_register_returns_apphook

# 需要导入模块: from cms import app_base [as 别名]
# 或者: from cms.app_base import CMSApp [as 别名]
def test_apphook_pool_register_returns_apphook(self):
        @apphook_pool.register
        class TestApp(CMSApp):
            name = "Test App"
        self.assertIsNotNone(TestApp)

        # Now test the quick return codepath, when apphooks is not empty
        apphook_pool.apphooks.append("foo")

        @apphook_pool.register
        class TestApp2(CMSApp):
            name = "Test App 2"
        self.assertIsNotNone(TestApp2) 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:15,代码来源:test_apphooks.py

示例3: _verify_apphook

# 需要导入模块: from cms import app_base [as 别名]
# 或者: from cms.app_base import CMSApp [as 别名]
def _verify_apphook(apphook, namespace):
    """
    Verifies the apphook given is valid and returns the normalized form (name)
    """
    apphook_pool.discover_apps()
    if isinstance(apphook, CMSApp):
        try:
            assert apphook.__class__ in [app.__class__ for app in apphook_pool.apps.values()]
        except AssertionError:
            print(apphook_pool.apps.values())
            raise
        apphook_name = apphook.__class__.__name__
    elif hasattr(apphook, '__module__') and issubclass(apphook, CMSApp):
        return apphook.__name__
    elif isinstance(apphook, six.string_types):
        try:
            assert apphook in apphook_pool.apps
        except AssertionError:
            print(apphook_pool.apps.values())
            raise
        apphook_name = apphook
    else:
        raise TypeError("apphook must be string or CMSApp instance")
    if apphook_pool.apps[apphook_name].app_name and not namespace:
        raise ValidationError('apphook with app_name must define a namespace')
    return apphook_name 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:28,代码来源:api.py


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