[Zope3-Users] Re: NotYet error when creating content during container creation

Alek Kowalczyk thealx at poczta.onet.pl
Wed Feb 28 12:46:46 EST 2007


Philipp von Weitershausen <philipp at ...> writes:

> > I don't think I would like to redesign my objects just because the
> > addIntIdSubscriber does not catch NotYet when getting IKeyReference:
> > 
> >  <at> adapter(ILocation, IObjectAddedEvent)
> > def addIntIdSubscriber(ob, event):
> >     # ...
> >     utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
> >     if utilities: # assert that there are any utilites
> >         key = IKeyReference(ob, None) # HERE IS RAISED EXCEPTION
> >         # ...
> > 
> 
> Why not write a custom IKeyReference adapter that doesn't raise the 
> exception? You could even let the adaption fail completely so that the 
> addIntIdSubscriber gets a None for 'key' and doesn't proceed:
> 
>  <at> adapter(YourClass)
> def keyReference(obj):
>      return None # adaption failed on purpose, don't want key references
> 

Yeah, you are right! This looks as the simplest solution, much simpler than
overriding addIntIdSubscriber in some way (if it is possible, which I'm not sure)

Warm regards!
Alek



More information about the Zope3-users mailing list