[Zope-dev] delObject errors and aq_base

Kevin Dangoor kdangoor@webelite.com
Tue, 4 Sep 2001 15:35:43 -0400


----- Original Message -----
From: "John Ziniti" <jziniti@speakeasy.org>
To: <zope-dev@zope.org>
Sent: Tuesday, September 04, 2001 1:56 PM
Subject: [Zope-dev] delObject errors and aq_base


> I received an error message when attempting to delete an
> object:
>
> Error Value: examples does not exist
>
> 'examples' is a folder from the Zope tutorial.  In my
> messing around, I have found that this occurs because
> OFS/ObjectManager, in method _getObj, calls (more
> or less):
>
> hasattr(aq_base(self), id)
>
> This returns 0 unless I change it to:
>
> hasattr(self, id)

This makes it sound like you're trying to delete examples from a folder
below examples. hasattr(aq_base(self), id) will check within that one object
without doing any acquisition. hasattr(self, id) will look up the
acquisition chain for a matching attribute. Making this change would
probably produce undesirable results.

> Further checking shows that self is of type
> Acquisiton.ImplicitAcquirerWrapper but that aq_base(self) is
> of type OFS.Folder.Folder.

That makes sense. Generally, everything you work with in Zope is an
Acquisition wrapper (which allows you to do all of that nifty stuff with
Acquisition, like acquiring standard_html_header, etc.). aq_base gives you
the unwrapped object.

> Is this a bug?  Is my ZODB hosed (I do a lot of weird stuff)?
> Any workaround besides changing the code, deleting the objects
> and changing the code back? Any side-effects to that approach?
> What did I do to get it like this?

I doubt your ZODB is hosed, but it's hard to tell from your description
exactly why you're not having luck deleting the object. Are you trying to
delete from the management interface or from a script of some sort?

Kevin