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:
return
if not ti.allowType(obj.getPortalTypeName()):
raise ValueError(u'Disallowed subobject type: %s' %
type_name)
Cheers, Yuppie
_______________________________________________
Zope-CMF maillist - [email protected]
http://mail.zope.org/mailman/listinfo/zope-cmf
See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests