Re: [Zope3-Users] recursive constraints

2005-08-22 Thread Gary Poster


On Aug 22, 2005, at 9:00 AM, Markus Leist wrote:


Hello,

there are a few (older) mails about "recursive constraints" in Zope3.
I wasn't able to find a solution for this small problem:

in interface.py:

class IIkGroup(IIkSClass):
def __setitem__(name, object):
"""Add a IIkGroup object."""
__setitem__.precondition = ItemTypePrecondition( IIkInterface)
[...]


only Instances of IkInterface are allowed to add, ok so far.

Now it should be possible to add an Instance of IkGroup (on itself)?
"... ItemTypePrecondition( IIkGroup, IIkInterface) ..." is a stupid  
idea, because

pathon don't know IIkGroup() at this time.

I don't wont to implement an "IContained"-mechanism and
setTaggedValue... seems to be obsolete - is this possible?


Hi Markus.  Yes, it is somewhat ugly to do, but possible.  If you  
look at how the zope.app.container constraint stuff works you should  
be able to figure how to do it.  Essentially, even though we mostly  
want interfaces to be immutable, they are not.  If you mutate them  
right after you construct them--adding a 'precondition' attribute to  
__setitem__, for instance--you should be able to swallow your  
distaste and get the behavior you want. :-)


Gary

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] recursive constraints

2005-08-22 Thread Markus Leist
Hello,

there are a few (older) mails about "recursive constraints" in Zope3.
I wasn't able to find a solution for this small problem:

in interface.py:

class IIkGroup(IIkSClass):
def __setitem__(name, object):
"""Add a IIkGroup object."""
__setitem__.precondition = ItemTypePrecondition( IIkInterface)
[...]


only Instances of IkInterface are allowed to add, ok so far.

Now it should be possible to add an Instance of IkGroup (on itself)?
"... ItemTypePrecondition( IIkGroup, IIkInterface) ..." is a stupid idea, 
because
pathon don't know IIkGroup() at this time.

I don't wont to implement an "IContained"-mechanism and 
setTaggedValue... seems to be obsolete - is this possible?

Markus
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users