本文整理汇总了Python中Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault.getLayout方法的典型用法代码示例。如果您正苦于以下问题:Python ISelectableBrowserDefault.getLayout方法的具体用法?Python ISelectableBrowserDefault.getLayout怎么用?Python ISelectableBrowserDefault.getLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault
的用法示例。
在下文中一共展示了ISelectableBrowserDefault.getLayout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _context_selected_layout
# 需要导入模块: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 别名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 别名]
def _context_selected_layout(self):
"""Return the current layout for the layout aware context if we
are on the layout aware context
"""
if not ILayoutAware(self.context, None):
return ''
selectable_layout = ISelectableBrowserDefault(self.context, None)
if not selectable_layout:
return ''
return selectable_layout.getLayout()
示例2: upgrade_9_to_10
# 需要导入模块: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 别名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 别名]
def upgrade_9_to_10(context):
from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault
types_tool = getToolByName(context, 'portal_types')
pc = getToolByName(context, 'portal_catalog')
# Iterate through all Dexterity content type
all_ftis = types_tool.listTypeInfo()
dx_ftis = [x for x in all_ftis if getattr(x, 'behaviors', False)]
for fti in dx_ftis:
if not (LAYOUT_BEHAVIORS & set(fti.behaviors)):
continue
results = pc.unrestrictedSearchResults(portal_type=fti.id)
for brain in results:
ob = brain._unrestrictedGetObject()
ob_default = ISelectableBrowserDefault(ob, None)
if ob_default is None:
continue
if ob_default.getLayout() in ['view', '@@view']:
ob_default.setLayout('layout_view')
示例3: getMenuItems
# 需要导入模块: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 别名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 别名]
#.........这里部分代码省略.........
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
if folderCanSetDefaultPage:
results.append({
'title': _(u'label_change_default_item',
default=u'Change content item as default '
u'view...'),
'description': _(u'title_change_default_view_item',
default=u'Change the item used as default'
u' view in this folder'),
'action': '%s/select_default_page' % (folderUrl,),
'selected': False,
'icon': None,
'extra': {
'id': 'folderChangeDefaultPage',
'separator': 'actionSeparator',
'class': 'pat-plone-modal'},
'submenu': None,
})
# 2. Render context options
if context is not None:
contextUrl = obj.absolute_url()
selected = context.getLayout()
defaultPage = context.getDefaultPage()
layouts = context.getAvailableLayouts()
if useSeparators:
results.append({
'title': _(u'label_current_item_views',
default=u'Item display'),
'description': '',
'action': None,
'selected': False,
'icon': None,
'extra': {
'id': 'contextHeader',
'separator': 'actionSeparator',
'class': ''},
'submenu': None,
})
# If context is a default-page in a folder, that folder's views
# will be shown. Only show context views if there are any to show.
showLayouts = False
if not isDefaultPage:
showLayouts = True
elif len(layouts) > 1:
showLayouts = True
if showLayouts and contextCanSetLayout:
for id, title in contextLayouts:
is_selected = (defaultPage is None and id == selected)
results.append({
'title': title,
示例4: getMenuItems
# 需要导入模块: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 别名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 别名]
def getMenuItems(self, context, request):
# Check required parameters
if context is None or request is None:
return []
# Get layout vocabulary factory
vocab_factory = getUtility(IVocabularyFactory,
name='plone.availableDisplayLayouts')
# Get context state API
context_state = getMultiAdapter((context, request),
name='plone_context_state')
# Get folder layout options when this is a default page
folder_layout = ''
folder_methods = []
folder_results = []
folder_url = ''
folder_vocab = []
if context_state.is_default_page():
folder = parent(context)
if folder is not None:
folder_methods = getAvailableViewMethods(folder)
folder_url = folder.absolute_url()
folder_vocab = vocab_factory(folder)
folder_default = ISelectableBrowserDefault(folder, None)
if folder_default is not None:
folder_layout = folder_default.getLayout()
for term in folder_vocab or []:
if term.value in folder_methods:
is_selected = term.value == folder_layout
id_ = term.value.split('++')[-1]
actionUrl = '%s/selectViewTemplate?templateId=%s' % (
folder_url, quote(term.value),),
if HAS_PLONE_PROTECT:
actionUrl = addTokenToUrl(actionUrl, request)
folder_results.append({
'title': term.title,
'description': '',
'action': actionUrl,
'selected': is_selected,
'icon': None,
'extra': {
'id': 'folder-layout-' + id_,
'separator': None,
'class': is_selected and 'actionMenuSelected' or ''},
'submenu': None,
})
# Get context layout options
context_methods = getAvailableViewMethods(context)
context_results = []
context_url = context.absolute_url()
context_vocab = vocab_factory(context)
context_default = ISelectableBrowserDefault(context, None)
if context_default is not None:
context_layout = context_default.getLayout()
for term in context_vocab:
if term.value in context_methods:
is_selected = term.value == context_layout
id_ = term.value.split('++')[-1]
actionUrl = '%s/selectViewTemplate?templateId=%s' % (
context_url, quote(term.value),)
if HAS_PLONE_PROTECT:
actionUrl = addTokenToUrl(actionUrl, request)
context_results.append({
'title': term.title,
'description': '',
'action': actionUrl,
'selected': is_selected,
'icon': None,
'extra': {
'id': 'plone-contentmenu-layout-' + id_,
'separator': None,
'class': is_selected and 'actionMenuSelected' or ''},
'submenu': None,
})
# Merge the results with the original display meny
menu = getUtility(IBrowserMenu, 'plone_contentmenu_display')
results = []
for result in menu.getMenuItems(context, request):
id_ = (result.get('extra') or {}).get('id')
sep = (result.get('extra') or {}).get('separator')
# Extend results with layouts
if id_ in ('folderHeader', 'contextHeader'):
pass
elif sep and id_.startswith('folder') and folder_results:
results.extend(folder_results)
folder_results = []
elif sep and id_.startswith('context') and context_results:
results.extend(context_results)
context_results = []
# Move 'Custom layout' into bottom
if id_ in ['folder-view', '[email protected]@view']:
folder_results.append(result)
elif id_ in ['plone-contentmenu-display-view',
#.........这里部分代码省略.........