[Zope-CMF] Re: ActionProviderBase.getActionById

Yuppie schubbe at web.de
Fri Oct 10 15:35:44 EDT 2003


Hi!


I guess you just forgot to send a copy to the list. I'll CC the list again.

alan runyan wrote:
>>> Could we land a getActionById on ActionProviderBase.  In plone
>>> we have tons of code that iterates through actions just to
>>> grab a specific action by its id.  Anyone see any downsides?
>>
>>
>> +1 in general
>>
>> Some thoughts regarding details:
>>
>> 1.) We can't call this method getActionById. In CMF 1.4 and later 
>> TypeInformation subclasses from ActionProviderBase and its 
>> getActionById interface / implemtation doesn't make much sense in the 
>> context of ActionInformation objects. TypeInformation's getActionById 
>> was written for oldstyle type actions. I'd propose 'getActionInfo'.
> 
> 
> thats fine.  I was thinking simpler.  Something that relieved the client
> from iterating (its such a PITA).  I was just goign to return a copy
> of the ActioIfno object.  i.e. alot of times we need to check visibile
> or category, etc.
> 
>> 2.) I'm not sure what identifies an Action: Id isn't unique. Id + 
>> Category would be more specific, but isn't unique either. Don't know 
>> what makes sence.
> 
> 
> I think this isnt a problem.  The problem is you cant query Actions
> on a Tool (I *know* Reply is on portal_discussion, but _cloneActions()
> and all that jazz is getting painful).  I just want to walk up to a tool
> and get the ActionById. Given a id+category is enough. If it returns
> multiple items - fine.

I don't know if it makes sense to return more than one item. The only 
case with identical ids that comes to my mind is this in ActionsTool:

     _actions = (ActionInformation(id='folderContents'
                                 , title='Folder contents'
                                 , action=Expression(
                text='string: ${folder_url}/folder_contents')
                                 , condition=Expression(
                text='python: folder is not object')
                                 , permissions=(ListFolderContents,)
                                 , category='object'
                                 , visible=1
                                  )
               , ActionInformation(id='folderContents'
                                 , title='Folder contents'
                                 , action=Expression(
                text='string: ${folder_url}/folder_contents')
                                 , condition=Expression(
                text='python: folder is object')
                                 , permissions=(ListFolderContents,)
                                 , category='folder'
                                 , visible=1
                                  )
                )

Looking at the conditions, only one is true in any case. It might be 
sufficient to return the first action with the given id that fulfills 
the Condition / Permission / visibility.

I don't know if people use categories to distinguish between actions 
having the same id. If not, it would be easier to just use id.

> Although I dont like the query/get diachotomy
> of method names.  queryActionInfo might be fine.

Isn't it like this: You *query* the Action Provider and *get* an Action 
Info as result?

>> 3.) The method should return the result of ActionInformation.getAction .
> 
> 
> hrmmm, I would like the opportunity to check if its visible.

ok.

>> 4.) The method should check Permissions and Condition.
> 
> 
> ok.
> 
>> 5.) It should be possible to pass a chain of action ids. If 
>> Permissions / Condition check fails on the first one, return the next.
> 
> 
> sounds fine with me.  +1
> 
> ~runyaga

I'd like to keep listFilteredActionsFor, getActionInfo and getAction in 
sync. getActionInfo should return the same dict as the others.

What about flags for visibility and Permissions?

     def getActionInfo(object=None, action_chain,
                       check_visible=1, check_permissions=1):


Cheers,
	Yuppie





More information about the Zope-CMF mailing list