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


Python IActionProvider.providedBy方法代码示例

本文整理汇总了Python中Products.CMFCore.interfaces.IActionProvider.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python IActionProvider.providedBy方法的具体用法?Python IActionProvider.providedBy怎么用?Python IActionProvider.providedBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Products.CMFCore.interfaces.IActionProvider的用法示例。


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

示例1: listFilteredActionsFor

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:31,代码来源:ActionsTool.py

示例2: _extractOldstyleActions

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:34,代码来源:actions.py

示例3: _extractConfiglets

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:35,代码来源:controlpanel.py

示例4: cleanupActionProviders

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
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,代码行数:10,代码来源:betas.py

示例5: listFilteredActionsFor

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:45,代码来源:ActionsTool.py

示例6: hidePropertiesAction

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
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,代码行数:12,代码来源:betas.py

示例7: getMenuItems

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:57,代码来源:menu.py

示例8: listFilteredActionsFor

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
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,代码行数:49,代码来源:ActionsTool.py

示例9: available

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:19,代码来源:menu.py

示例10: available

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:20,代码来源:menu.py

示例11: _extractOldstyleActions

# 需要导入模块: from Products.CMFCore.interfaces import IActionProvider [as 别名]
# 或者: from Products.CMFCore.interfaces.IActionProvider import providedBy [as 别名]
    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,代码行数:38,代码来源:actions.py


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