[Zope-dev] Re: Utility factory handling for zope.component

Philipp von Weitershausen philipp at weitershausen.de
Wed Jul 23 12:26:16 EDT 2008


Wichert Akkerman wrote:
> Stephan Richter wrote:
>> On Wednesday 23 July 2008, Wichert Akkerman wrote:
>>   
>>> If there are no objections I intend to merge the branch to trunk in a
>>> few days
>>>     
>>
>> I am uncomfortable with the way you approached this. I think there are at 
>> least two other possibilities that I can see without having looked closer:
>>
>> 1. Use the info object. The point of the info is to contain this sort of 
>> information.
>>   
> 
> Which info object are you referring to? The only information I could see 
> for utility registration is a tuple, not an object. This is used to 
> build the UtilityRegistration object when querying registration 
> information, and I added a factory method there.

I think Stephan is referring to the (formerly) last item of the tuple, 
which is available as utility_reg.info. It contains information about 
how the component was registered, for instance the ZCML file name + line 
number.

It looks like Stephan is suggesting to do something like this:

   component = factory()
   registry.registerUtility(component, info=InfoAbout(factory))

whereas Wichert's approach allows you to write:

   registry.registerUtility(factory=factory)

I prefer Wichert's approach.


More information about the Zope-Dev mailing list