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

Martin Aspeli optilude at gmx.net
Fri Sep 26 18:04:49 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?

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Grok-dev mailing list