request.registry.registerUtility(...)request.registry.getUtility(...)request.registry.registrerUtility(foo_factory, IFactory, 'Foo')mycontext = zope.configuration.config.ConfigurationMachine()
mycontext.registry = request.registrymyfoo = createObject('Foo', context=mycontext)request.registry.getUtility(IFactory, 'Foo')()--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/46ff94d2-ef9e-4741-9d64-ae8e9e11cf8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I know almost nothing about what you just asked but I will point you to https://docs.pylonsproject.org/projects/pyramid/en/1.9-branch/narr/zca.html#using-the-zca-global-api-in-a-pyramid-application as well as the `config.hook_zca` method.- Michael
On Wed, Sep 13, 2017 at 12:20 PM, Julian Sanchez <forei...@gmail.com> wrote:
After reading how to use the zca page I've managed to register a few utilities and adapters throughandrequest.registry.registerUtility(...)request.registry.getUtility(...)How can you hook up the zope.component.createObject method? I did myrequest.registry.registrerUtility(foo_factory, IFactory, 'Foo')
but of course creatObject by itself will go against the global repository (and of course I get the dreaded 'could not adapt' error)I tried the trick:mycontext = zope.configuration.config.ConfigurationMachine()
mycontext.registry = request.registry..and thenmyfoo = createObject('Foo', context=mycontext)But that also returns 'could not adapt'Is my only option to do arequest.registry.getUtility(IFactory, 'Foo')()
instead of createObject?Thanks,Julian
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.