本文整理汇总了Python中cms.toolbar_base.CMSToolbar方法的典型用法代码示例。如果您正苦于以下问题:Python toolbar_base.CMSToolbar方法的具体用法?Python toolbar_base.CMSToolbar怎么用?Python toolbar_base.CMSToolbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cms.toolbar_base
的用法示例。
在下文中一共展示了toolbar_base.CMSToolbar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from cms import toolbar_base [as 别名]
# 或者: from cms.toolbar_base import CMSToolbar [as 别名]
def register(self, toolbar):
import warnings
if toolbar.__module__.split('.')[-1] == 'cms_toolbar':
warnings.warn('cms_toolbar.py filename is deprecated, '
'and it will be removed in version 3.4; '
'please rename it to cms_toolbars.py', DeprecationWarning)
if not self.force_register and get_cms_setting('TOOLBARS'):
return toolbar
from cms.toolbar_base import CMSToolbar
# validate the app
if not issubclass(toolbar, CMSToolbar):
raise ImproperlyConfigured('CMS Toolbar must inherit '
'cms.toolbar_base.CMSToolbar, %r does not' % toolbar)
name = "%s.%s" % (toolbar.__module__, toolbar.__name__)
if name in self.toolbars.keys():
raise ToolbarAlreadyRegistered("[%s] a toolbar with this name is already registered" % name)
self.toolbars[name] = toolbar
return toolbar
示例2: test_register
# 需要导入模块: from cms import toolbar_base [as 别名]
# 或者: from cms.toolbar_base import CMSToolbar [as 别名]
def test_register(self):
pool = ToolbarPool()
pool.register(TestToolbar)
pool.register(CMSToolbar)
self.assertEqual(pool.toolbars, {
'cms.toolbar_base.CMSToolbar': CMSToolbar,
'cms.tests.test_toolbar_pool.TestToolbar': TestToolbar})
self.assertRaises(ToolbarAlreadyRegistered,
pool.register, TestToolbar)
示例3: test_register_order
# 需要导入模块: from cms import toolbar_base [as 别名]
# 或者: from cms.toolbar_base import CMSToolbar [as 别名]
def test_register_order(self):
pool = ToolbarPool()
pool.register(TestToolbar)
pool.register(CMSToolbar)
test_toolbar = OrderedDict()
test_toolbar['cms.tests.test_toolbar_pool.TestToolbar'] = TestToolbar
test_toolbar['cms.toolbar_base.CMSToolbar'] = CMSToolbar
self.assertEqual(list(test_toolbar.keys()), list(pool.toolbars.keys()))