[Zope] POSKeyError

Jeremy M. Smith jeremy@ucdavis.edu
Wed, 28 May 2003 16:11:09 -0700


Thank you *so* much. Improvising around the code you provided, I was 
able to delete the errant UserFolder object and re-create it. The 
POSKeyError is no more. If you don't object, I'd like to create a howto 
on this topic at one of the Zope sites. I spent two days searching 
through news archives, Google results, etc. looking for something like 
this with no luck, though it seems many others have experienced similar 
errors.

Again, thanks.

Jeremy.

Dieter Maurer wrote:

>Jeremy M. Smith wrote at 2003-5-27 15:36 -0700:
> > ...
> > With this one folder, I get a POSKeyError. After researching this 
> > problem online, I used the fsrefs.py utility to determine which object 
> > it is that's not being found, but I can't figure out how to either a) 
> > get that object back (since I can't access the management screens due to 
> > the error) or b) remove the invalid references. I have seen some 
> > references to truncating (a copy of) the Data.fs just before the 
> > transaction that causes the error, but I haven't found any instructions 
> > on how to do this.
>
>You know that you can access the ZODB outside of Zope?
>
>For this to be possible, you must either stop Zope or use ZEO.
>
>It then looks like this (I assume a Unix setup with "bash";
>the shell commands are different for Windows):
>
>   # you are inside your Zope directory
>   export PYTHONPATH=$PYTHONPATH:$PWD/lib/python
>   python
>   from Zope import app
>   root= app() # "root" contains your root object
>   obj= root.unrestrictedTraverse(url_to_obj)
>
>   # assume, "obj" now contains the folder with the dangling
>   # reference; we must find the id belonging to the reference
>   for id,val in obj.objectItems():
>     try: val.getId()
>     except POSKeyError: break
>   # "id" should now contain the id with the broken object
>   # we give it a new one
>   obj._setOb(id,DTMLMethod('',__name__=id))
>   # now we delete it
>   obj.manage_delObject(id)
>   # commit
>   get_transaction().commit()
>
>The script is not complete. You must import "POSKeyError" and
>"DTMLMethod" and provide "url_to_obj".
>
>
>Dieter
>  
>

-- 

Jeremy M. Smith <jeremy@ucdavis.edu>
Computer Systems Administrator
Center for Mind and Brain
University of California, Davis