[Zope-dev] Restricting Sub-Objects in Folders DYNAMICALLY?

Max M maxm@mxm.dk
Sat, 16 Mar 2002 19:40:53 +0000


Brian Oliver wrote:

> For example:  I'd like to restrict the number of a certain type of 
> object that may appear in a folder.  The end-user can add up to the 
> limit, and afterwards the object type should NO LONGER APPEAR in the 
> "Add List".


If you put this in your product:

    def all_meta_types(self):
        """ What types can you add to this objectManager? """
        allowedMetaTypes = ('DTML Document', 'DTML Method')
        result = []
        for metaType in Products.meta_types:
            if metaType['name'] in allowedMetaTypes:
                result.append(metaType)
        return result

You can probably modify it to your needs.

regards Max M