Wichert Akkerman wrote:
> Previously yuppie wrote:
>> A CMF specific precondition would look up type restrictions in the fti 
>> of the container.
>> checkFactory and checkObject are quite similar to isConstructionAllowed. 
>> I think we should reimplement this based on zope.container before we 
>> start adding new features.
> I looked at the code in zope.container and frankly it scared me. I found
> the documentation and code hard to follow, and the usage of
> sys._getframe() made me drop the idea of using it.

That scary code is used for supporting 'contains' declarations in the 
interface. I don't propose to write something similar for CMF.

AFAICS it is sufficient to set __setattr__.precondition directly for 
supporting checkObject.

A precondition that just checks allowType would look like this:

   class PortalTypePrecondition:

       def __call__(self, container, name, obj):

           ti = container.getTypeInfo()
           if ti is None:

           if not ti.allowType(obj.getPortalTypeName()):
               raise ValueError(u'Disallowed subobject type: %s' % 

Cheers, Yuppie

Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Reply via email to