[Zope-CMF] Proposal: Add 'changeAction' method to ActionProviderBase.ActionProviderBase

Gregoire Weber gregweb at gmx.ch
Wed Jun 23 07:17:06 EDT 2004


Hi Tres!

I'd like to add the below changeAction method to ActionProviderBase.
Any Objections?
Can I put that into the branch for CMF 1.5? Is it the head?
I'd really like to have it in the upcoming CMF 1.5 if possible.

Gregoire

----------------------------------------------------------------------
<code source="CMFCore.ActionProvider.py">

_unchanged = [] # marker
class ActionProviderBase
    # [...]

    security.declareProtected( ManagePortal, 'changeAction' )
    def changeAction( self
                    , id
                    , new_id=_unchanged
                    , title=_unchanged
                    , description=_unchanged
                    , category=_unchanged
                    , condition=_unchanged
                    , permissions=_unchanged
                    , priority=_unchanged
                    , visible=_unchanged
                    , action=_unchanged
                    ):
        """Changes the specified properties of the action with id 'id'.
        """
        # get the action beeing changed
        action_ids = [a.getId() for a in self._actions]
        pos = action_ids.index(id)
        current = actions[pos]

        # clone unchanged properties
        if new_id is _unchanged:
            new_id = current.getId()
        if title is _unchanged:
            title = current.title
        if description is _unchanged:
            description = current.description
        if category is _unchanged:
            category = current.category
        if condition is _unchanged:
            condition = current.condition
        if permissions is _unchanged:
            permissions = current.permissions
        if priority is _unchanged:
            priority = current.priority
        if visible is _unchanged:
            visible = current.visible
        if action is _unchanged:
            action = current.getActionExpression()
        
        new = ActionInformation( new_id
                               , title=title
                               , description=description
                               , category=category
                               , condition=condition
                               , permissions=permissions
                               , priority=priority
                               , visible=visible
                               , action=action)
        
        # replace the current action by the new one
        actions = list(self._actions)
        actions[pos] = new
        self._actions = tuple(actions)

</code>

----------------------------------------------------------------------
<code source="CMFCore.interfaces.portal_actions.py">

_unchanged = [] # marker
class ActionProvider(Interface):
    '''The interface expected of an object that can provide actions.
    '''
    def listActions(info=None):
        # [...]

    def changeAction( id
                    , new_id=_unchanged
                    , title=_unchanged
                    , description=_unchanged
                    , category=_unchanged
                    , condition=_unchanged
                    , permissions=_unchanged
                    , priority=_unchanged
                    , visible=_unchanged
                    , action=_unchanged
                    ):
        """Changes the specified properties of the action with id 'id'.
        """

</code>




More information about the Zope-CMF mailing list