[Grok-dev] Re: Registering a factory as a grok.GlobalUtility fails

Jan-Wijbrand Kolman janwijbrand at gmail.com
Wed May 9 08:16:18 EDT 2007


On 5/9/07, Jan-Wijbrand Kolman <janwijbrand at gmail.com> wrote:
> I want to register a (content)factory using grok.GlobalUtility.
> However this fails during grok time with an maximum recursion depth
> exceeded error. I can reproduce it with the following functional test
> (in a module called 'factoryutility'py' in 'grok/ftests/utility'):
>
> """
>   >>> import grok
>   >>> from zope import component
>   >>> from grok.ftests.utility.local import *
>   >>> grok.grok('grok.ftests.utility.factoryutility')
> """
>
> import grok
>
> class ObjectFactory(grok.GlobalUtility):
>     grok.implements('IFactory')
>     grok.name('objectfactory')
>
>     def __call__(self):
>         return object()
>
> Do I do something wrong here? I have, again, no clue...

...after some more trying. This test fails in the same way:

"""
  >>> import grok
  >>> from zope import component
  >>> from grok.ftests.utility.local import *
  >>> grok.grok('grok.ftests.utility.factoryutility')
"""

import grok

class ObjectFactory(object):
    grok.implements('IFactory')
    grok.name('objectfactory')

    def __call__(self):
        return object()

grok.global_utility(ObjectFactory, direct=True)

And this test does *not* fail:

"""
  >>> import grok
  >>> from zope import component
  >>> from grok.ftests.utility.local import *
  >>> grok.grok('grok.ftests.utility.factoryutility')
"""

import grok

class ObjectFactory(object):
    grok.name('objectfactory')

    def __call__(self):
        return object()

grok.global_utility(ObjectFactory, provides=IFactory, direct=True)


kind regards,
jw
-- 
Jan-Wijbrand Kolman


More information about the Grok-dev mailing list