[Grok-dev] Re: Global utilities registered too early?
janwijbrand at gmail.com
Tue Jun 19 07:42:46 EDT 2007
> I'm trying to create/register a global utility by subclassing
> grok.GlobalUtility. If I understand correctly, exactly one instance of
> this utility class is created at registration time, right? It is this
> instance that is returned when calling getUtility, right?
> Now, in my case the __init__ of my utility class makes use of other
> global utilities that are registered by a "third party" package
> (called userschema). However, when creating the instance for my
> utility class, the "third party" utilities are not registered (yet)
> and thus cannot be found.
> I'm not sure I fully understand why this is the case (and thus I do
> not see a way around it yet). I also tried to <include
> package="userschema" ?> just before the <grok:grok package="."/>
> directive in my package's configure.zcml, but to no avail; My global
> utility seems always to be registered before the utilities from
> userschema are registered.
> Maybe somebody can nudge me in the right direction with this?
FYI: I put a print statement in registerUtility() in z.c.registry and
indeed it seems utilities that are registered thru grok are registered
*before any other* utility that gets registered in core zope packages
and "third party non-grok" pacakges. HTH.
More information about the Grok-dev