[Zope-dev] Survey: most obscure errors

Edwin Grubbs edwin.grubbs at canonical.com
Thu Sep 16 13:52:47 EDT 2010


> From: Marius Gedminas <marius at gedmin.as>
> Date: Tue, Sep 14, 2010 at 11:00 AM
> Subject: [Zope-dev] Survey: most obscure errors
> To: zope-dev at zope.org
>
>
> What are the most obscure error conditions you've encountered while
> developing Zopeish[1] applications?
>
>  [1] ZTK, Grok, Bluebream, the old Zope 3.x KGSes all qualify.
>
> I'm talking about situations where the error message/traceback are
> disconnected from the actual cause.  For example, forgetting to add a
> security declaration in ZCML can cause TraversalError (because
> ForbiddenAttribute is a subclass of AttributeError), which leads the
> developer off to a wild goose chase looking for why the attribute is
> missing (was it misspelled? did it come from an old database?) the first
> few times this kind of error happens.
>
> One of the goals we came up with in the Zope Summit in Halle was to
> identify the most annoying of these kinds of error messages and fix
> them.  I need your help for the identifying part!
>
> Marius Gedminas


The most common confusing error that I encounter is when some
underlying code has an AttributeError, but zope's traversal code
doesn't tell me about that exception, it just tells me that the
attribute several layers up could not be traversed.

For example, there is a bug in a function like this:

def format_data(foo):
    return "%d: %s" % (foo.id, foo.name)

def baz(foo_id):
    foo = load_foo(foo_id)
    return format_data(foo)

class FooView:
    @property
    def my_foo(self):
         return baz(self.context.foo_id)

When the template tries to traverse view/my_foo, if foo doesn't have
the "name" attribute, it fails, but it only tells you that my_foo
couldn't be found on the view. I used to spend quite a bit of time
trying to figure out whether I changed some configuration that caused
this error. If the attribute was on a context object with a security
wrapper, I would be checking that also. Now, I usually recognize that
I have to add pdb.set_trace() inside of my_foo so that I can see where
the AttributeError is really raised.

I reported the bug two years ago, but I guess I didn't explain the
problem very well.
https://bugs.edge.launchpad.net/zope3/+bug/311062

-Edwin


More information about the Zope-Dev mailing list