[Zope-CMF] Re: Plone needs a release this week

yuppie y.2007- at wcm-solutions.de
Tue Aug 7 06:49:32 EDT 2007


Wichert Akkerman wrote:
> Previously yuppie wrote:
>> Wichert Akkerman wrote:
>>> I get something else: if I import this:
>>>
>>>  <utility interface="foo.IBar" factory="foo.bar"/>
>>>
>>> the export looks like this:
>>>
>>>  <utility interface="foo.IBar" object=""/>
>> That seems to be a similar but different bug.
>>
>>> this is caused by the zope.component.registerUtility not storing the
>>> factory method but the return value from the factory, so we no longer
>>> have the factory method available when we export.
>>>
>>> The only way to fix that appears to be for us to keep a a registry of
>>> factory methods in the setup tool. That may be too big of a change
>>> in a minor release though.
>> Not sure if your issue is a problem in real life. AFAICS this only 
>> happens if you use a factory that is meant for ZODB objects. In that 
>> case you should register an object.
> 
> Ah, that makes sense I guess. My test-case was this:
> 
>    from Products.MailHost.MailHost import MailHost
>    def genMail():
>        return MailHost()
> 
>    <utility interface="Products.MailHost.interfaces.IMailHost"
>             factory="Products.GenericSetup.hack.genMail"/>
> 
> and a MailHost is indeed a ZODB object.

The check for aq_base should be fine, but your example shows a second 
issue: type() is used to get the factory. That only works if the class 
is the factory.

So there seems to be indeed a need to store somewhere the factory name :(


Cheers, Yuppie



More information about the Zope-CMF mailing list