Skip to content

Instantly share code, notes, and snippets.

@dirceu
Created November 25, 2008 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dirceu/29057 to your computer and use it in GitHub Desktop.
Save dirceu/29057 to your computer and use it in GitHub Desktop.
# The following code can be used to delete an object that is return POSKeyErrors
# on a ZODB database. Run it using 'zopectl debug'. Tested with Zope 2.9.
container_id = '/path/to/container'
screwed_object_id = 'screwed_obj'
from ZODB.POSException import POSKeyError
import transaction
obj = app.unrestrictedTraverse(container_id)
obj._objects = tuple(filter(lambda i,n = id: i['id'] != n, obj._objects))
delattr(obj, screwed_object_id)
transaction.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment