[Zope3-dev] Heads up: planning to restructure zope.app.uniqueid

Dominik Huber dominik.huber at projekt01.ch
Tue Nov 30 07:06:47 EST 2004


Hi Jim,
I added an explicit context to the getAllUtilitiesRegisteredFor lookup
of the removeIntIdSubscriber and the addIntIdSubsriber.

The following use case was not covered by the current implementation: 

I'm using an InitializeSubscriber witch subcribes Initializables to
ObjectAddedEvent. 
This InitializeSubscriber calls the initialize method of an
initializable object, 
after the object is added and it lives in its full context. 
This initialize method can be used to register a intid-utility or sub
content for example.
The following example should illustrate the use case:

class IInitializable(Interface):
  def initialize():
    """Inialize the object after its ObjectAddedEvent"""

class L(Location):
  pass

class S(ServiceManagerContainer, BTreeContainer):
  implement(IInitializable)

  def initialize(self):
    # do after addition initialization...
    addSiteManager(self)
    addLocalUtilityService(self)
    addLocalUtility(self, u'', IIntIds, IntIds())

    # add content
    self['sub'] = L()

Add a content object 's' of S TTW to the root. 
Object 's' is added and s.initialize() is called by the
InitializeSubscriber.
After the intid-utitility is added an additional child 'sub' of 's' is
added too. 
This child 'sub' is not going to be registered within the
intid-utility of 's',
because the implicit context of the utitility lookup inside the
addIntIdSubsriber is the root and *not*
the context of child 'sub' (only one implicit context per
transaction).

With the explicit context the intid utitility of 's' is found and the
object 'sub' will be registered as expected.

I hope that's ok. Otherwise, I'm going to redo as usual ;)

Regards,
Dominik Huber
Projekt01 GmbH
__________________________________
END OF MESSAGE 




More information about the Zope3-dev mailing list