[Zope3-dev] Re: registerUtility(component, interface) vs provideUtility(interface, component) vs provideUtility(component, interface)

Christian Theune ct at gocept.com
Sat Sep 2 11:57:16 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Philipp von Weitershausen wrote:
> Christian Theune wrote:
>> Philipp von Weitershausen wrote:
>>> Christian Theune wrote:
>>>> see subject. What's the reason that all three flavours (still?)
>>>> exist? I
>>>>  just had a really hard time finding the spelling I need.
>>> ztapi.provideUtility(interface, component) is discouraged and should go
>>> away. I didn't do this for Zope 3.3 because of a lack of time.
>>>
>>> zope.component.provideUtility(component, interface=optional) is a
>>> convenience spelling for:
>>>
>>>   zope.component.getGlobalSiteManager().registerUtility(
>>>       component, interface=optional).
>>>
>>> The order of arguments is the same. I think Jim wants the convenience
>>> functions in zope.component (provide*) to go away in favor of the
>>> explicit spelling through the global site manager. I think that before
>>> we do that, we should first abolish the term "site manager" from the
>>> zope.component API (because we don't call it site manager anymore).
>>
>> Hmm. Hmm. zope.component.provide* is *very* convenient. What would the
>> new spelling be?
> 
> Look two paragraphs above:
> 
>>>   zope.component.getGlobalSiteManager().registerUtility(
>>>       component, interface=optional).


Ouch, sorry for beeing stupid there. Should have read that.

>> Isn't the global site manager something else then zope.component?
> 
> No. The global site manager (we prefer to call it global component
> registry nowadays) is defined in zope.component. It is always htere.
> 
>> Because zope.component uses the current thread-local site-manager,
>> depending on what was set during traversal etc., isn't it?
> 
> Nope. zope.component knows nothing about thread-local site managers.
> That's zope.app.component (which hooks its knowledge of thread-local
> site managers into zope.component).

So why does zope.component.getUtility return local utilities then?

Christian

- --
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE+ancdUt9X/gknwIRAlFVAJ0Ss3Qcd5nTMomqpdf/ZKrKIXdiGACfRvz/
Dl+aaSJbMOqi20NuIiqgLxo=
=ApeK
-----END PGP SIGNATURE-----


More information about the Zope3-dev mailing list