[Grok-dev] grokcore.component registring Components

Christian Klinger cklinger at novareto.de
Tue Nov 29 13:12:39 UTC 2011


Hi,

sorry one mistake...

   if site is None:
       sm = zope.component.getGlobalSiteManager()

- Christian


> Hi,
>
> together with Souheil we tried to use z3c.baseregistry[1] together with
> GROK. Out of the box it does not work, because grokcore.component uses
> some functions (provideUtility, provideAdatper, ...) from
> zope.component. Souheil discoverd that this function use *always* the
> globalSiteManager, which makes problems together with z3c.baseregistry.
>
> We created a simple function (my_provideUtility) which works, Is it
> possible to integrate this in grokcore.component? Are there any risks?
>
> Thanks for your Help
> Christian
>
> [1] http://pypi.python.org/pypi/z3c.baseregistry
>
> ----------------%<------------------------------------------------------
>
> def my_provideUtility(component, provides=None, name=u''):
> site = zope.component.hooks.getSite()
> if site is None:
> sm = zope.component.getSiteManager()
> else:
> sm = site.getSiteManager()
> sm.registerUtility(component, provides, name, event=False)
>
>
> class GlobalUtilityGrokker(martian.ClassGrokker):
> ...
>
> def execute(self, factory, config, direct, provides, name, **kw):
> if not direct:
> factory = factory()
> config.action(
> discriminator=('utility', provides, name),
> callable=my_provideUtility,
> args=(factory, provides, name),
> )
> return True
>
> ----------------------->%---------------------------------------------------
>




More information about the Grok-dev mailing list