当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.ISelectableBrowserDefault类代码示例

本文整理汇总了Python中Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault的典型用法代码示例。如果您正苦于以下问题:Python ISelectableBrowserDefault类的具体用法?Python ISelectableBrowserDefault怎么用?Python ISelectableBrowserDefault使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ISelectableBrowserDefault类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_isMixedIn

 def test_isMixedIn(self):
     self.assertTrue(isinstance(self.af, BrowserDefaultMixin),
                     "ISelectableBrowserDefault was not mixed in to ATFolder")
     self.assertTrue(ZopeTwoISelectableBrowserDefault.providedBy(self.af),
                     "ISelectableBrowserDefault not implemented by ATFolder instance")
     self.assertTrue(ISelectableBrowserDefault.providedBy(self.af),
                     "ISelectableBrowserDefault not implemented by ATFolder instance")
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:7,代码来源:test_browserdefaultmixin.py

示例2: _context_selected_layout

 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()
开发者ID:ispires,项目名称:plone.app.mosaic,代码行数:10,代码来源:widget.py

示例3: get_target_object_layout

 def get_target_object_layout(self, target):
     """
     Returns target object 'view' action page template
     """
     if ISelectableBrowserDefault.providedBy(target):
         return target.getLayout()
     else:
         return 'base_view'
开发者ID:collective,项目名称:collective.newsletter,代码行数:8,代码来源:newsletter.py

示例4: rename_default_page

def rename_default_page(obj, event):
    newParent = event.newParent
    if newParent != event.oldParent:
        return
    elif ISelectableBrowserDefault.providedBy(newParent):
        default_page_id = newParent.getProperty('default_page', '')
        if default_page_id == event.oldName:
            ISelectableBrowserDefault(newParent).setDefaultPage(event.newName)
开发者ID:urska19,项目名称:Plone-test,代码行数:8,代码来源:browserdefault.py

示例5: upgrade_9_to_10

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')
开发者ID:neilferreira,项目名称:plone.app.mosaic,代码行数:21,代码来源:upgrades.py

示例6: rename_default_page

def rename_default_page(obj, event):
    """event subscriber, rename default page if targte was renamed

    used by default for zope.lifecycleevent.interfaces.IObjectMovedEvent
    """
    newParent = event.newParent
    if newParent != event.oldParent:
        return
    elif ISelectableBrowserDefault.providedBy(newParent):
        default_page_id = newParent.getProperty("default_page", "")
        if default_page_id == event.oldName:
            ISelectableBrowserDefault(newParent).setDefaultPage(event.newName)
开发者ID:pigaov10,项目名称:plone4.3,代码行数:12,代码来源:browserdefault.py

示例7: getTargetObjectLayout

 def getTargetObjectLayout(self, target):
     """
     Returns target object 'view' action page template
     """
     
     if HAS_ISBD and ISelectableBrowserDefault.isImplementedBy(target):
         return target.getLayout()
     else:
         view = target.getTypeInfo().getActionById('view') or 'base_view'
         
         # If view action is view, try to guess correct template
         if view == 'view':
             view = target.portal_type.lower() + '_view'
             
         return view
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:15,代码来源:TabbedSubpages.py

示例8: available

    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
开发者ID:RBINS,项目名称:plone.app.contentmenu,代码行数:46,代码来源:menu.py

示例9: getMenuItems

    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
#.........这里部分代码省略.........
开发者ID:RBINS,项目名称:plone.app.contentmenu,代码行数:101,代码来源:menu.py

示例10: test_extendsInterface

 def test_extendsInterface(self):
     self.failUnless(ISelectableBrowserDefault.extends(IBrowserDefault))
开发者ID:pigaov10,项目名称:plone4.3,代码行数:2,代码来源:test_browserdefault.py

示例11: test_extendsInterface

 def test_extendsInterface(self):
     self.assertTrue(ISelectableBrowserDefault.extends(IBrowserDefault))
开发者ID:plone,项目名称:Products.CMFDynamicViewFTI,代码行数:2,代码来源:test_browserdefault.py

示例12: getMenuItems

    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',
#.........这里部分代码省略.........
开发者ID:amitsaroj001,项目名称:plone.app.mosaic,代码行数:101,代码来源:layoutmenu.py


注:本文中的Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。