[Zope-CMF] Extending FTI.isConstructionAllowed

Charlie Clark charlie at begeistert.org
Wed Jun 3 04:29:29 EDT 2009


Am 03.06.2009 um 10:12 schrieb Wichert Akkerman:

> There are two reasons I want to block creation of the object:  
> performance, and user interface. The last one is more critical: the  
> add-item menus used in Plone (and I suspect CMF as well) look for  
> all object types that can be constructed in the current location.  
> Obviously you do not want to do that by creating all possible  
> objects and testing if you can add them to the container, so we need  
> a way to test if creating an object and adding it to the current  
> container is allowed without creating objects.


I agree with you on the UI aspect! In which case, surely you should be  
looking to set a precondition on checkFactory?

class IItemTypePrecondition(zope.interface.Interface):

     def __call__(container, name, object):
         """Test whether container setitem arguments are valid.

         Raise zope.interface.Invalid if the object is invalid.
         """

     def factory(container, name, factory):
         """Test whether objects provided by the factory are acceptable

         Return a boolean value.
         """

It looks to me like the factory method is the place to do the  
checking. But I guess the problem is integrating this with the  
TypeInfo.allowed_content_types ?

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226





More information about the Zope-CMF mailing list