本文整理匯總了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()))