本文整理汇总了Python中Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault.canSetDefaultPage方法的典型用法代码示例。如果您正苦于以下问题:Python ISelectableBrowserDefault.canSetDefaultPage方法的具体用法?Python ISelectableBrowserDefault.canSetDefaultPage怎么用?Python ISelectableBrowserDefault.canSetDefaultPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault
的用法示例。
在下文中一共展示了ISelectableBrowserDefault.canSetDefaultPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: available
# 需要导入模块: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 别名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import canSetDefaultPage [as 别名]
def available(self):
if self.disabled():
return False
isDefaultPage = self.context_state.is_default_page()
folder = None
context = None
folderLayouts = []
contextLayouts = []
# If this is a default page, also get menu items relative to the parent
if isDefaultPage:
folder = ISelectableBrowserDefault(utils.parent(self.context),
None)
context = ISelectableBrowserDefault(self.context, None)
folderLayouts = []
folderCanSetLayout = False
folderCanSetDefaultPage = False
if folder is not None:
folderLayouts = folder.getAvailableLayouts()
folderCanSetLayout = folder.canSetLayout()
folderCanSetDefaultPage = folder.canSetDefaultPage()
contextLayouts = []
contextCanSetLayout = False
contextCanSetDefaultPage = False
if context is not None:
contextLayouts = context.getAvailableLayouts()
contextCanSetLayout = context.canSetLayout()
contextCanSetDefaultPage = context.canSetDefaultPage()
# Show the menu if we either can set a default-page, or we have more
# than one layout to choose from.
if (folderCanSetDefaultPage) or \
(folderCanSetLayout and len(folderLayouts) > 1) or \
(folder is None and contextCanSetDefaultPage) or \
(contextCanSetLayout and len(contextLayouts) > 1):
return True
else:
return False
示例2: getMenuItems
# 需要导入模块: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 别名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import canSetDefaultPage [as 别名]
def getMenuItems(self, obj, request):
"""Return menu item entries in a TAL-friendly form."""
results = []
context_state = getMultiAdapter(
(obj, request), name='plone_context_state'
)
isDefaultPage = context_state.is_default_page()
parent = None
folder = None
if isDefaultPage:
# If this is a default page, also get menu items relative to thr
# parent
parent = utils.parent(obj)
folder = ISelectableBrowserDefault(parent, None)
folderLayouts = []
folderCanSetLayout = False
folderCanSetDefaultPage = False
if folder is not None:
folderLayouts = folder.getAvailableLayouts()
folderCanSetLayout = folder.canSetLayout()
folderCanSetDefaultPage = folder.canSetDefaultPage()
contextLayouts = []
contextCanSetLayout = False
contextCanSetDefaultPage = False
context = ISelectableBrowserDefault(obj, None)
if context is not None:
contextLayouts = context.getAvailableLayouts()
contextCanSetLayout = context.canSetLayout()
contextCanSetDefaultPage = context.canSetDefaultPage()
# Short circuit if neither folder nor object will provide us with
# items
if not (folderCanSetLayout or folderCanSetDefaultPage or
contextCanSetLayout or contextCanSetDefaultPage):
return []
# Only show the block "Folder display" and "Item display" separators if
# they are necessars
useSeparators = False
if folderCanSetLayout or folderCanSetDefaultPage:
if (contextCanSetLayout and len(contextLayouts) > 1) or \
contextCanSetDefaultPage:
useSeparators = True
# 1. If this is a default-page, first render folder options
if folder is not None:
folderUrl = parent.absolute_url()
if useSeparators:
results.append({
'title': _(u'label_current_folder_views',
default=u'Folder display'),
'description': '',
'action': None,
'selected': False,
'icon': None,
'extra': {'id': 'folderHeader',
'separator': 'actionSeparator',
'class': ''},
'submenu': None,
})
if folderCanSetLayout:
for id, title in folderLayouts:
results.append({
'title': title,
'description': '',
'action': addTokenToUrl(
'%s/selectViewTemplate?templateId=%s' % (
folderUrl, id,), request),
'selected': False,
'icon': None,
'extra': {
'id': 'folder-' + id,
'separator': None,
'class': ''},
'submenu': None,
})
# Display the selected item (i.e. the context)
results.append({
'title': _(u'label_item_selected',
default=u'Item: ${contentitem}',
mapping={'contentitem': escape(
utils.safe_unicode(obj.Title()))}),
'description': '',
'action': None,
'selected': True,
'icon': None,
'extra': {
'id': 'folderDefaultPageDisplay',
'separator': 'actionSeparator',
'class': 'actionMenuSelected'},
'submenu': None,
})
# Let the user change the selection
#.........这里部分代码省略.........