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

Roger Ineichen dev at projekt01.ch
Thu Feb 17 23:11:17 EST 2005


Hi Tom
> -----Original Message-----
> From: zope3-users-bounces at zope.org 
> [mailto:zope3-users-bounces at zope.org] On Behalf Of Tom Dossis
> Sent: Friday, February 18, 2005 4:45 AM
> To: zope3-users at zope.org
> Subject: [Zope3-Users] specifying a container precondition to 
> contain itself
> 
> 
> How could I achieve the following declaration without getting 
> the error:
> NameError: 'IGameFolder' is not defined?
> 
> 
> class IGame(Interface):
>      pass
> 
> class IGameFolder(IContainer):
> 
>      def __setitem__(name, object):
> 	"""Add a game or game sub folder """
> 
>      __setitem__.precondition = ItemTypePrecondition(IGame, 
> IGameFolder)
> 
> 
> My current work around looks pretty ugly..
> 
> class IGameFolder(IContainer):
> 
>      def __setitem__(name, object):
> 	"""Add a game or game sub folder """
> 
>      __setitem__.precondition = ItemTypePrecondition(IGame)
> 
> IGameFolder['__setitem__'].setTaggedValue('precondition',
>      ItemTypePrecondition(IGame, IGameFolder)
>      )

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)

Regards
Roger Ineichen

Projekt01 GmbH
www.projekt01.ch
_____________________________
END OF MESSAGE  

 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 



More information about the Zope3-users mailing list