[Zope3-dev] Re: Recursive containment constraints
Jim Fulton
jim at zope.com
Fri Sep 17 03:15:56 EDT 2004
Tres Seaver wrote:
> Stephan Richter wrote:
>
>> On Wednesday 15 September 2004 09:01, Dominik Huber wrote:
>>
>>> Month ago I read the contenttype part of stephan's book. at that time he
>>> used
>>> setTaggedValue to solve recursive containment constraints:
>>>
>>> 43 IMessage['__setitem__'].setTaggedValue('precondition',
>>> 44
>>> ItemTypePrecondition(IMessage))
>>> 45 IMessage.setTaggedValue('__parent__', Field(
>>> 46 constraint=ContainerTypesConstraint(IMessageBoard,
>>> IMessage)))
>>>
>>> Today I wanted to use the setTaggedValue('__parent__', Field(...))
>>> approach but it
>>> seems not work anymore. Is that right?
>>
>>
>>
>> No, it should still work. I did not change to another pattern for
>> technical reasons.
>>
>>
>>> >>> '__parent__' in IMessage.names('all')
>>> False
>>>
>>> The new version of the book solves this problem with two indepentent
>>> interfaces IMessage
>>> and IMessageContained. Is that the 'official' pattern people should
>>> follow?
>>
>>
>>
>> Yeah, I think this is the recommended pattern. I changed to this one,
>> since it is easier to read and understand. Also, all sample
>> applications use this pattern as well.
>
>
> In reality, I think we would be better off moving the constraint
> declarations out of the classes;
You mean "interfaces" or "class statements" :)
> that would both remove the "forward
> reference" problem and make it easy to move to a "containment constraint
> registry" solution when that became available.
>
> My biggest reason for wanting this is that the constraints are *policy*,
They often are, but aren't always.
But, I agree, that we almost certainly want to move the constraints out
of the interfaces.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list