[Zope3-Users] specifying a container precondition to contain itself

Tom Dossis td at yoma.com.au
Thu Feb 17 23:54:28 EST 2005


Roger Ineichen wrote:
> Use a interface for a hook like:
> 
> class IGameFolderContained(Interface):
> 
> 
> class IGameFolder(IContainer):
> 
>      def __setitem__(name, object):
> 	"""Add a game or game sub folder """
> 
>      __setitem__.precondition = ItemTypePrecondition(IGameFolderContained)
> 
> 
> And use in the classes GameFolder and Game
> implements(IGameFolderContained)
> 
That did the trick.
I didn't mention IGame also had: 
__parent__=Field(constraint=ContainerTypesConstraint(IGameFolder))
which necessitated an additional hook.
Thanks
-Tom


More information about the Zope3-users mailing list