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) Further checking shows that self is of type Acquisiton.ImplicitAcquirerWrapper but that aq_base(self) is of type OFS.Folder.Folder. 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? -- John Ziniti Channing Laboratory Brigham and Women's Hospital 181 Longwood Avenue Brookline, MA 02115 john.ziniti@channing.harvard.edu
----- 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
......................................... Making this change would probably produce undesirable results.
Darn, seems like the easy way :)
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?
This is all happening within the ZMI. One thing I've noticed is this problem only occurs for items in the root. i.e., I can add items in the root folder but I can't delete them. Anywhere else and nothing goes wrong. It seems weird to me that within OFS.Folder.Folder._getOb, repr(self) is '<Folder instance at b54098>' and repr(aq_base(self)) is '<Folder instance b54098>', so we're dealing with the same object ... but getattr only works for the wrapped object, not the unwrapped one ... hrmmm ... One other thing that I find interesting is that sprinkling other print '%s' % (self) throughout OFS files mostly show OFS.Application.Application and <Apllication instance at bd92b8> instead of OFS.Folder -- John Ziniti Channing Laboratory Brigham and Women's Hospital 181 Longwood Avenue Brookline, MA 02115 john.ziniti@channing.harvard.edu
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?
This is all happening within the ZMI. One thing I've noticed is this problem only occurs for items in the root. i.e., I can add items in the root folder but I can't delete them. Anywhere else and nothing goes wrong. It seems weird to me that within OFS.Folder.Folder._getOb, repr(self) is '<Folder instance at b54098>' and repr(aq_base(self)) is '<Folder instance b54098>', so we're dealing with the same object ... but getattr only works for the wrapped object, not the unwrapped one ... hrmmm ...
Acquisition wrappers *look* a lot like the base object. But, as you mentioned in your original message, they're of different types. repr on the wrapper may look like the base object, but it searches that object and all the way up the chain to find the attributes you're looking for.
One other thing that I find interesting is that sprinkling other print '%s' % (self) throughout OFS files mostly show OFS.Application.Application and <Apllication instance at bd92b8> instead of OFS.Folder
The root object is an Application... I'm not sure what that Folder is that you're encountering... Kevin Dangoor Product Development Manager Web Elite http://www.webelite.com
The root object is an Application... I'm not sure what that Folder is that you're encountering...
<oops> Thanks for the help and the sage advice to not go ahead and delete with impunity :) ... I just realized what was going on and it's not a Zope problem at all but a poorly written rewrite rule for Apache which is rewriting the request for delObjects into another folder ... where, of course, the object 'examples' does not exist ... :) At least I have a better understandind of "how it works" ... Thanks again. sorry for the trouble ... </oops> -- John Ziniti Channing Laboratory Brigham and Women's Hospital 181 Longwood Avenue Brookline, MA 02115 john.ziniti@channing.harvard.edu
participants (2)
-
John Ziniti -
Kevin Dangoor