[Zope] preventing add list pollution - how?
Dieter Maurer
dieter@handshake.de
Mon, 5 Aug 2002 19:28:00 +0200
Oliver Bleutgen writes:
> I knew the best practice to do that, but I forgot it, and don't find the
> solution on zope or elsewhere, and probably I'm confused.
>
> Say I have a container product, and objects which just will be added to
> that container or its subobjects. Therefore I don't want the subobjects
> to appear in the general add list, just in the add list of the container.
> I know how to manipulate that add-lists, my problem is what to do with
> the subobjects to get them into zope "properly".
>
> Do I write my subobjects like normal zope product, just without
> registering them with zope as products?
> Do I then add instance of my subobjects to a container just using
> _.setObject?
I do it like this (for a CMF site):
class ContainerProduct(...):
...
def all_meta_types(self):
'''return list of allowed meta types.'''
return (
{
'name' : PortalConfig.meta_type,
'action': 'PortalConfig_add', # that's a skin form, calling "addPortalConfig"
'permission': ManagePortal,
},
)
def addPortalConfig(self,id,title='',RESPONSE=None):
'''add Portal Config object.'''
o= PortalConfig(); o.id= id; o.title= title
self._setObject(id,o)
if RESPONSE is not None:
RESPONSE.redirect('%s/manage_main' % self.absolute_url())
class PortalConfig(...):
...
Dieter