Integrating ZMI&CMF (was: Re: [Zope-CMF] Change invokeFactory !)
Oliver Bleutgen
myzope@gmx.net
Tue, 19 Feb 2002 17:42:25 +0100
Tres Seaver wrote:
>>
>>could you qualify this a little. I.e. I'm writing my own (python)
>>product for the CMF and want to use the ZMI as a frontend. So I know my
>>product doesn't do something which is hidden somewhere in the types
>>tool, at least not hidden by me.
>>Are there some caveats I should know about?
>>
>
> If your product defines a content type class, the site manager may
> create an arbitrairy number of content types which are backed by it;
> your object must not assume that it knows anything about which skins,
> workflows, metadata policies, etc. are bound to it. Constructing it
> via the ZMI is going to be painful, as well, because you won't know
> which "type" your object is supposed to be.
>
> If you plan to use this product only in your own site, then obviously
> you can choose not to observe these guidelines, as you, the prouct
> developer, will know exactly how you, the site manager, will be using
> your class.
>
> Tres.
Thanks for your answer,
I'll just add one snippet so that perhaps this may help someone else who
also wants to "integrate" ZMI and CMF. One thing I did to get some of
the flexiblity the CMF offers into the ZMI interface is dynamically
constructing ZMI's manage_options from the types tool's getActions().
def _manage_options(self):
"""private methods to dynamically construct manage_options for the
ZMI via ComputedAttribute"""
all_product_actions = self.getTypeInfo().getActions()
product_actions = filter(lambda x: x['category'] == 'object',
all_product_actions)
my_actions_list = []
for a in product_actions:
ma = {}
ma['label'] = a['name']
ma['action'] = a['action']
my_actions_list.append(ma)
my_actions = tuple(my_actions_list)
options = my_actions + self._core_options
return options
manage_options = ComputedAttribute(_manage_options,1)
cheers,
oliver