Comment 3 for bug 311062

Revision history for this message
Jean Jordaan (jean-jordaan) wrote :

Edwin explained this again on [zope-dev]. It does indeed seem a lot clearer than the above ;-)
So I'm adding his explanation from the list:

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.