[Grok-dev] five.grok - what changed to break this?

sylvain at infrae.com sylvain at infrae.com
Sat Sep 27 01:59:13 EDT 2008


> Martin Aspeli wrote:
>
>> I struggle to guess what that adapter may be or why there's two of it,
>> but my guess would be the static/ folder stuff?
>
> Turns out to be a good guess. I've just checked in a workaround for some
> code that was obviously broken:
>
> Index: src/five/grok/meta.py
> ===================================================================
> --- src/five/grok/meta.py	(revision 91534)
> +++ src/five/grok/meta.py	(working copy)
> @@ -59,16 +59,18 @@
>                           "resource directory and a module named "
>                           "'static.py'", module_info.getModule())
>
> -        # FIXME: This is public, we need to set security on resources ?
> -        name = module_info.dotted_name
> -        resource_factory = components.DirectoryResourceFactory(
> -            name, resource_path)
> -        adapts = (IDefaultBrowserLayer,)
> -        provides = interface.Interface
> +            # FIXME: This is public, we need to set security on resources
> ?
> +            name = module_info.dotted_name
> +            resource_factory = components.DirectoryResourceFactory(
> +                name, resource_path)
> +            adapts = (IDefaultBrowserLayer,)
> +            provides = interface.Interface
>
> -        config.action(
> -            discriminator=('adapter', adapts, provides, name),
> -            callable=component.provideAdapter,
> -            args=(resource_factory, adapts, provides, name),
> -            )
> -        return True
> +            config.action(
> +                discriminator=('adapter', adapts, provides, name),
> +                callable=component.provideAdapter,
> +                args=(resource_factory, adapts, provides, name),
> +                )
> +            return True
> +
> +        return False
> \ No newline at end of file
>
> That is, it was registering the 'static' resource directory adapter even
> when there was no 'static/' directory to be found!
>
> I didn't break any tests with this change. I should've written a failing
> test to prove it, but I don't have time for that right now and I need my
> instance to start up. :)
>
> I suspect my fix didn't actually fix the problem, though. I think it
> merely worked around it because my package doesn't have a static/
> directory.
>
>> How would I debug this?
>
> That question still stands - how would I've debugged this if my guessing
> wasn't so good?
>


  Like in Grok you don't include yourself in your meta.zcml a dependency
to grokcore.view, here neither. five.grok include for your only usefull
parts of grokcore.view, and redefines others.

  You should just remove that, and have in your zcml:

  <include package="five.grok" file="meta.zcml" />
  <include package="five.grok" />

  And nothing else.

  This should works afterwards. This have been disscussed on the Grok
mailing list, how to redefine the static adapter in five.grok.

  Best regards,

  Sylvain,








More information about the Grok-dev mailing list