Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

Utility factory handling for zope.component

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


wichert at wiggy

Jul 23, 2008, 3:00 AM

Post #1 of 7 (300 views)
Permalink
Utility factory handling for zope.component

Tools like GenericSetup which deal with mangement of utility
registration are a bit handicapped at the moment: even though you can
register a utility using a factory the utility registration itself
only runs the factory methods but does not keep any information on it.
As a result you can not round-trip utility registration information or
check if the current configuration has changed from an original
configuration.

To fix that I made a wichert-utility-factories branch of zope.component
which adds the factory information to the utility registration. All
changes are fully backbwards compatible at both the API and persistence
level.

If there are no objections I intend to merge the branch to trunk in a
few days.

Wichert.

--
Wichert Akkerman <wichert[at]wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


srichter at cosmos

Jul 23, 2008, 8:24 AM

Post #2 of 7 (285 views)
Permalink
Re: Utility factory handling for zope.component [In reply to]

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.

2. Make the component have a "factory" attribute. I have done this at some
places for APIDOC as well.

Option 1 seems the cleanest because it was designed d for this.

Regards,
Stephan
--
Stephan Richter
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


wichert at wiggy

Jul 23, 2008, 8:29 AM

Post #3 of 7 (284 views)
Permalink
Re: Utility factory handling for zope.component [In reply to]

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.

> 2. Make the component have a "factory" attribute. I have done this at some
> places for APIDOC as well.
>

Why would a component need to know how it was created? I can envision
that a component may very well have an attribute named factory for
something else entirely.

Wichert.

--
Wichert Akkerman<wichert[at]wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.


tseaver at palladion

Jul 23, 2008, 8:36 AM

Post #4 of 7 (285 views)
Permalink
Re: Utility factory handling for zope.component [In reply to]

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

Wichert Akkerman wrote:
> Tools like GenericSetup which deal with mangement of utility
> registration are a bit handicapped at the moment: even though you can
> register a utility using a factory the utility registration itself
> only runs the factory methods but does not keep any information on it.
> As a result you can not round-trip utility registration information or
> check if the current configuration has changed from an original
> configuration.
>
> To fix that I made a wichert-utility-factories branch of zope.component
> which adds the factory information to the utility registration. All
> changes are fully backbwards compatible at both the API and persistence
> level.
>
> If there are no objections I intend to merge the branch to trunk in a
> few days.

+1.


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIh0/1+gerLs4ltQ4RAqvmAJ9ZhukVeDLQ+MiBTTYtDC6NkEEwYACcCIUn
CpxkKLgOfJjmdulFMgOuqtE=
=rKeM
-----END PGP SIGNATURE-----
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


tseaver at palladion

Jul 23, 2008, 8:36 AM

Post #5 of 7 (284 views)
Permalink
Re: Utility factory handling for zope.component [In reply to]

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

Wichert Akkerman wrote:
> Tools like GenericSetup which deal with mangement of utility
> registration are a bit handicapped at the moment: even though you can
> register a utility using a factory the utility registration itself
> only runs the factory methods but does not keep any information on it.
> As a result you can not round-trip utility registration information or
> check if the current configuration has changed from an original
> configuration.
>
> To fix that I made a wichert-utility-factories branch of zope.component
> which adds the factory information to the utility registration. All
> changes are fully backbwards compatible at both the API and persistence
> level.
>
> If there are no objections I intend to merge the branch to trunk in a
> few days.

+1.


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIh0/1+gerLs4ltQ4RAqvmAJ9ZhukVeDLQ+MiBTTYtDC6NkEEwYACcCIUn
CpxkKLgOfJjmdulFMgOuqtE=
=rKeM
-----END PGP SIGNATURE-----

_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


philipp at weitershausen

Jul 23, 2008, 9:26 AM

Post #6 of 7 (285 views)
Permalink
Re: Utility factory handling for zope.component [In reply to]

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.
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


srichter at cosmos

Jul 23, 2008, 11:50 AM

Post #7 of 7 (285 views)
Permalink
Re: Re: Utility factory handling for zope.component [In reply to]

On Wednesday 23 July 2008, Philipp von Weitershausen wrote:
> 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.

Oh, I thought the "component" argument was still required making factory a
documentation artifact. In this case I am okay.

Regards,
Stephan
--
Stephan Richter
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.