[z3-five] Fix found! Re: Local utilities enhancements +
GenericSetup for 1.4?
Lennart Regebro
regebro at gmail.com
Thu Feb 23 13:18:27 CET 2006
I looked even more closely into this yesterday, and realised I have
misunderstood how the Zope3 API worked.
This is how it works:
When registering a local utility, the interface argument is optional.
However, not specifying and interface only works when the utility
implements one and only one interface.
It is always available for all inherited interfaces, even when an
interface is specified. That is, with the following setup:
class IMyInterface(Interface):
pass
class IMyDerivedInterface(IMynterface):
pass
class MyUtility(persistent):
implements(IMyDerivedInterface)
utility = MyUtility()
registerUtility(component, IMyDerivedInterface)
This call will return the utility:
zapi.getUtility(IMyInterface)
In Five, it will currently not. The utility will only be derived with this call:
zapi.getUtility(IMyDerivedInterface)
I have now checked in a fix for this, on the branch:
http://codespeak.net/svn/z3/Five/tag/regebro-localutility-fix
I will merge this into both trunk and 1.3 branch this afternoon or
tomorrow unless somebody objects.
On my previous suggestions, they are currently dropped. Changing the
API turned out to not be necessary to implement this. It's not an
effect of the API, it's in fact a simple bug. We will still need to
change the API of course, but not until Zope 3.3/2.10/Five1.5.
And as mentioned previously, I will instead put the export/import
adpaters into GenericSetup after Zope 2.10 is released.
More information about the z3-five
mailing list