本文整理匯總了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
#.........這裏部分代碼省略.........