當前位置: 首頁>>代碼示例>>Python>>正文


Python interfaces.IActionProvider類代碼示例

本文整理匯總了Python中Products.CMFCore.interfaces.IActionProvider的典型用法代碼示例。如果您正苦於以下問題:Python IActionProvider類的具體用法?Python IActionProvider怎麽用?Python IActionProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IActionProvider類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: listFilteredActionsFor

    def listFilteredActionsFor(self, object=None):
        """ List all actions available to the user.
        """
        actions = []

        # Include actions from specific tools.
        for provider_name in self.listActionProviders():
            provider = getattr(self, provider_name)
            if IActionProvider.providedBy(provider):
                actions.extend( provider.listActionInfos(object=object) )

        # Include actions from object.
        if object is not None:
            if IActionProvider.providedBy(object):
                actions.extend( object.listActionInfos(object=object) )

        # Reorganize the actions by category.
        filtered_actions={'user':[],
                          'folder':[],
                          'object':[],
                          'global':[],
                          'workflow':[],
                          }

        for action in actions:
            catlist = filtered_actions.setdefault(action['category'], [])
            catlist.append(action)

        return filtered_actions
開發者ID:goschtl,項目名稱:zope,代碼行數:29,代碼來源:ActionsTool.py

示例2: _extractOldstyleActions

    def _extractOldstyleActions(self, provider_id):
        # BBB: for CMF 1.6 profiles
        fragment = self._doc.createDocumentFragment()

        provider = getToolByName(self.context, provider_id)
        if not (IActionProvider.providedBy(provider) or
                z2IActionProvider.isImplementedBy(provider)):
            return fragment

        if provider_id == 'portal_actions':
            actions = provider._actions
        else:
            actions = provider.listActions()

        if actions and isinstance(actions[0], dict):
            return fragment

        for ai in actions:
            mapping = ai.getMapping()
            child = self._doc.createElement('action')
            child.setAttribute('action_id', mapping['id'])
            child.setAttribute('category', mapping['category'])
            child.setAttribute('condition_expr', mapping['condition'])
            child.setAttribute('title', mapping['title'])
            child.setAttribute('url_expr', mapping['action'])
            child.setAttribute('visible', str(mapping['visible']))
            for permission in mapping['permissions']:
                sub = self._doc.createElement('permission')
                sub.appendChild(self._doc.createTextNode(permission))
                child.appendChild(sub)
            fragment.appendChild(child)
        return fragment
開發者ID:goschtl,項目名稱:zope,代碼行數:32,代碼來源:actions.py

示例3: _extractConfiglets

    def _extractConfiglets(self):
        fragment = self._doc.createDocumentFragment()

        provider = self.context
        if not IActionProvider.providedBy(provider):
            return fragment

        actions = provider.listActions()

        if actions and isinstance(actions[0], dict):
            return fragment

        if actions:
            actions = list(actions)
            actions.sort(key=lambda action: action.getMapping()['id'])

        for ai in actions:
            mapping = ai.getMapping()
            child = self._doc.createElement('configlet')
            child.setAttribute('action_id', mapping['id'])
            child.setAttribute('category', mapping['category'])
            child.setAttribute('condition_expr', mapping['condition'])
            child.setAttribute('title', mapping['title'])
            child.setAttribute('url_expr', mapping['action'])
            child.setAttribute('visible', str(mapping['visible']))
            child.setAttribute('appId', ai.getAppId())
            child.setAttribute('icon_expr', mapping['icon_expr'])
            for permission in mapping['permissions']:
                sub = self._doc.createElement('permission')
                sub.appendChild(self._doc.createTextNode(permission))
                child.appendChild(sub)
            fragment.appendChild(child)
        return fragment
開發者ID:JensenJiang,項目名稱:Products.CMFPlone,代碼行數:33,代碼來源:controlpanel.py

示例4: cleanupActionProviders

def cleanupActionProviders(context):
    """Remove no longer existing action proiders."""
    at = getToolByName(context, "portal_actions")
    for provider in at.listActionProviders():
        candidate = getToolByName(context, provider, None)
        if candidate is None or not IActionProvider.providedBy(candidate):
            at.deleteActionProvider(provider)
            logger.info("%s is no longer an action provider" % provider)
開發者ID:Vinsurya,項目名稱:Plone,代碼行數:8,代碼來源:betas.py

示例5: listFilteredActionsFor

    def listFilteredActionsFor(self, object=None,
                               ignore_providers=(),
                               ignore_categories=None):
        """ List all actions available to the user.
        """
        actions = []

        providers = [name for name in self.listActionProviders()
                     if name not in ignore_providers]

        # Include actions from specific tools.
        for provider_name in providers:
            provider = getattr(self, provider_name, None)
            # Skip missing action providers.
            if provider is None:
                continue
            if IActionProvider.providedBy(provider):
                if provider_name == 'portal_actions':
                    actions.extend(provider.listActionInfos(
                                   object=object,
                                   ignore_categories=ignore_categories
                                   ))
                else:
                    actions.extend(provider.listActionInfos(object=object))

        # Include actions from object.
        if object is not None:
            if IActionProvider.providedBy(object):
                actions.extend(object.listActionInfos(object=object))

        # Reorganize the actions by category.
        filtered_actions = {'user': [],
                            'folder': [],
                            'object': [],
                            'global': [],
                            'workflow': [],
                            }

        for action in actions:
            catlist = filtered_actions.setdefault(action['category'], [])
            catlist.append(action)

        return filtered_actions
開發者ID:JensenJiang,項目名稱:Products.CMFPlone,代碼行數:43,代碼來源:ActionsTool.py

示例6: hidePropertiesAction

def hidePropertiesAction(portal, out):
    tt = getToolByName(portal, "portal_types", None)
    if not IActionProvider.providedBy(tt):
        return
    for ti in tt.listTypeInfo():
        actions = ti.listActions()
        index = [i for i in range(len(actions)) if actions[i].category == "object" and actions[i].id == "metadata"]
        if index:
            ti.deleteActions(index)
            out.append("Removed properties action from type %s" % ti.id)
開發者ID:dtgit,項目名稱:dtedu,代碼行數:10,代碼來源:betas.py

示例7: getMenuItems

    def getMenuItems(self, context, request):
        # get standard factory types
        factories = super(FactoriesMenu, self).getMenuItems(context, request)

        # get factory actions from 'portal_types' action provider
        type_actions = []
        actions_tool = getToolByName(aq_inner(context), 'portal_actions')
        provider = getattr(actions_tool, 'portal_types', None)
        if IActionProvider.providedBy(provider):
            # Get folder_factories of container.
            context_state = getMultiAdapter((context, request),
                                            name='plone_context_state')
            if context_state.is_structural_folder():
                container = context
            else:
                container = context_state.folder()
            type_actions = provider.listActionInfos(object=container,
                           category='folder_factories')

        if type_actions:
            # WARNING: use of portal_actionicons is deprecated!
            plone_utils = getToolByName(context, 'plone_utils')
            portal_state = getMultiAdapter((context, request),
                                           name='plone_portal_state')
            portal_url = portal_state.portal_url()

            for action in type_actions:
                if action['allowed']:
                    cssClass = 'actionicon-folder_factories-%s' % action['id']
                    icon = action['icon']
                    if not icon:
                        icon = plone_utils.getIconFor('folder_factories',
                                                      action['id'],
                                                      None)
                        if icon:
                            icon = '%s/%s' % (portal_url, icon)

                    factories.append({
                            'title': action['title'],
                            'description': '',
                            'action': action['url'],
                            'selected': False,
                            'icon': icon,
                            'extra': {'id': action['id'],
                                             'separator': None,
                                             'class': cssClass},
                            'submenu': None,
                           })

        # order the actions
        factories.sort(key=lambda x: translate(x.get('title', u''),
                                               domain='plone',
                                               context=request))

        return self._post_cleanup_factories(context, request, factories)
開發者ID:4teamwork,項目名稱:ftw.contentmenu,代碼行數:55,代碼來源:menu.py

示例8: listFilteredActionsFor

def listFilteredActionsFor(self, object=None):
    """ List all actions available to the user.

    This patch removes inclusion of actions from the object itself.
    It was never used and now, it breaks objects inside Types Tool.

    It also checks for a new ERP5-only actions API (getActionListFor), but
    this API should be moved to listActionInfos() of each tool so as not to
    create duplicate code paths that are sources of bugs.

    Finally, this patch detects tools that are no longer action providers and
    invokes the migration of their actions to portal_actions
    """
    actions = []

    # Include actions from specific tools.
    for provider_name in self.listActionProviders():
        provider = getattr(self, provider_name)
        if hasattr(provider, 'getActionListFor'):
            from Products.ERP5Type.Utils import createExpressionContext
            ec = createExpressionContext(object)
            actions.extend(action.cook(ec)
                           for action in provider.getActionListFor(object)
                           if action.test(ec))
        elif IActionProvider.providedBy(provider):
            actions.extend( provider.listActionInfos(object=object) )
        else:
            # This should only be triggered once
            # We're in 2.12 and we need to migrate objects that are no longer
            # IActionProviders:
            migrateNonProviders(self)
            # Recompute from beginning
            return self.listFilteredActionsFor(object=object)

    actions.sort(key=lambda x:x.get('priority', 0))
    # Reorganize the actions by category.
    filtered_actions={'user':[],
                      'folder':[],
                      'object':[],
                      'global':[],
                      'workflow':[],
                      }

    for action in actions:
        filtered_actions.setdefault(action['category'], []).append(action)

    return filtered_actions
開發者ID:bhuvanaurora,項目名稱:erp5,代碼行數:47,代碼來源:ActionsTool.py

示例9: available

    def available(self):
        if self._addingToParent() and not self.context_state.is_default_page():
            return False
        if len(self._itemsToAdd()) > 0:
            return True
        if self._showConstrainOptions():
            return True

        actions_tool = getToolByName(self.context, 'portal_actions')
        provider = getattr(actions_tool, 'portal_types', None)
        if IActionProvider.providedBy(provider):
            type_actions = provider.listActionInfos(object=self.context,
                           category='folder_factories', max=1)
            if len(type_actions) > 0:
                return True

        return False
開發者ID:surmerming,項目名稱:ftw.contentmenu,代碼行數:17,代碼來源:menu.py

示例10: available

    def available(self):
        actions_tool = getToolByName(self.context, 'portal_actions')
        edit_actions = actions_tool.listActionInfos(object=self.context,
            categories=('object_buttons',), max=1)
        if len(edit_actions) > 0:
            return True

        provider = getattr(actions_tool, 'portal_types', None)
        if IActionProvider.providedBy(provider):
            type_actions = provider.listActionInfos(object=self.context,
                category='object_buttons', max=1)
            if len(type_actions) > 0:
                return True

        if self._has_transitions():
            return True

        return False
開發者ID:4teamwork,項目名稱:ftw.contentmenu,代碼行數:18,代碼來源:menu.py

示例11: _extractOldstyleActions

    def _extractOldstyleActions(self, provider_id):
        # BBB: for CMF 1.6 action settings
        # This method collects "old-style" action information and
        # formats it for import as "new-style" actions

        fragment = self._doc.createDocumentFragment()

        provider = getToolByName(self.context, provider_id)
        if not IActionProvider.providedBy(provider):
            return fragment

        if provider_id == 'portal_actions':
            actions = provider._actions
        else:
            actions = provider.listActions()

        if actions and isinstance(actions[0], dict):
            return fragment

        for ai in actions:
            if getattr(ai, 'getMapping', None) is None:
                continue
            mapping = ai.getMapping()
            child = self._doc.createElement('action')
            child.setAttribute('action_id', mapping['id'])
            child.setAttribute('category', mapping['category'])
            child.setAttribute('condition_expr', mapping['condition'])
            child.setAttribute('title', mapping['title'])
            child.setAttribute('url_expr', mapping['action'])
            child.setAttribute('visible', str(mapping['visible']))
            for permission in mapping['permissions']:
                sub = self._doc.createElement('permission')
                sub.appendChild(self._doc.createTextNode(permission))
                child.appendChild(sub)
            fragment.appendChild(child)
        return fragment
開發者ID:goschtl,項目名稱:zope,代碼行數:36,代碼來源:actions.py


注:本文中的Products.CMFCore.interfaces.IActionProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。