On Mon, May 16, 2005 at 05:18:08PM +0200, Michael Kaplan wrote:
I tried to follow the advice in http://www.zopelabs.com/cookbook/1095965033 (I use Zope-2.7.4) but end up with the 5th item there which says
!! !! 5. Get at the Zope path for the container of the object that's throwing the POSKeyError: !! !! >>> obj=root.unrestrictedTraverse('/path/to/container')
When I try this I get
obj=root.unrestrictedTraverse('/folder') Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'root' is not defined
what's wrong here? I don't know what the author of this text means with '/path/to/container' and what I have to put there for 'root'.
'root' is probably a misprint. If you're using the bin/zopectl script that comes with zope 2.7.x, you should substitute 'app' instead of 'root'. '/path/to/container' is a generic example. Substitute the path to any container you're interested in. The author of the recipe cannot predict what paths are of interest to you. Only you can know that.
Therefore I used fsrefs.py and got information like
oid 0x030571 Products.CMFCore.ActionInformation.ActionInformation last updated: 2005-03-14 08:20:34.643177, tid=0x35BE85493CF9666L refers to invalid object: oid 0x0304fa object creation was undone: 'Products.CMFCore.Expression.Expression'
For this oid I get
python Python 2.4 (#1, Jan 14 2005, 00:24:33) [GCC 2.95.3 20010315 (release)] on sunos5 Type "help", "copyright", "credits" or "license" for more information.
from Zope.Startup.run import configure;configure('/etc/zope.conf') from Zope import app app = app()
Note, there is a shortcut to the above: you can just run the command ./bin/zopectl debug
from ZODB.utils import p64 from ZODB import POSException obj = app._p_jar[p64(0x030571)] print obj.getId() view print obj.bobobase_modification_time() 2005/03/14 09:20:34.643 GMT+1 print obj.meta_type simple item
that's kind of unusual. Most Products have a more descriptive meta_type. Sounds like somebody wrote a subclass of OFS.Item.SimpleItem and did not bother to provide a proper meta_type in their code. Some grepping of source code in your Products directory might tell you what this thing really is.
print obj.__ac_local_roles__ None
Could anybody tell me, how I can delete this object from Data.fs? Will obj.manage_delObjects(id) do the job for me? What parameters do I have to give to the programm?
No, that would delete a sub-object of obj. If you want to delete obj itself, you have to find its parent folder first. You have found out an id ('view'), a mod time ('2005/03/14 09:20:34.643 GMT+1'), and a (weird) meta_type ('simple item'). That should give you some good clues for finding where this object lives, and thus find its parent folder. Once you know that, you can follow the zopelabs recipe. Unfortunately, there is no way to just ask a raw object for its physical path. You can call obj.getPhysicalPath() but it not tell you anything useful on a raw object (one directly loaded from _p_jar) because it is lacking its acquisition context. -- Paul Winkler http://www.slinkp.com