[Zope-CMF] [dev] refactoring listFilteredActionsFor: a proposal

Dieter Maurer dieter at handshake.de
Mon Nov 17 14:36:30 EST 2003


Yuppie wrote at 2003-11-16 19:08 +0100:
 > ...
 > 2.)
 > Action ids aren't unique.
 > I propose to identify actions by a path '<category>/<id>', e.g.:
 >    'object/edit', 'object/folderContents', 'folder/folderContents'
 > 
 > It's not enforced these paths are unique, but duplicates are ignored.

I may be an interesting use case to give different actions
the same id but use them with different (disjoint) conditions.

If you want to support such use cases, you should ignore
duplicates only after filtering.

Personally, I have no pressing need for these cases and I would
require that ids are unique (within a single ActionProvider).

 > 3.)
 > Action Providers should have a method that filters Actions. To avoid 
 > redundant code, listFilteredActionsFor could use this new method instead 
 > of listActions. The function of listFilteredActionsFor would not be 
 > filtering actions anymore, but aggregating actions from different 
 > sources and bucketing them into categories.

Very good idea!
The current "listFilteredActionsFor" is not very modular.

It may be a good idea to encapulate the filtering in its own
function. I have an "ActionFolder" product (a hierarchically
structured "ActionsProvider") that could benefit from such
factorization.

 > I propose to add these methods to the ActionProvider Interface:
 > 
 >      def listActionInfos(action_chain=None, object=None, ec=None,
 >                          max=999, check_visibility=1,
 >                          check_permissions=1, check_condition=1):
 >          """ List Action info mappings.
 > 
 >          Permission -- Python only

Why "Python only"?
 > 
 >          Returns -- Tuple of Action info mappings
 >          """

Proposals should not only provide the method's signature
but also describe (at least) the arguments and the return value.

I am scared about the "max" argument.
When you anticipate the need for such an argument, then you
should almost surely provide some way to limit the amount
of entries returned (such as e.g. interesting categories)
Some feedback may be required that the list has been truncated, as well.

-- 
Dieter



More information about the Zope-CMF mailing list