[Zope] ZODB Key error in root Zope database

Brian Brinegar brinegar at ecn.purdue.edu
Fri Feb 18 16:42:20 EST 2011


FYI,

I was able to successfully remove the cross storage reference in the
root of my main Zope database by explicitly setting the missing database
connection to a hacked DummyConnection instance. I probably could have
dug deeper to create a real connection, but this worked.

from ZODB import FileStorage, DB
import transaction

storage = FileStorage.FileStorage('Data.fs')
app = DB(storage).open().root()['Application']
base_conn = app._p_jar

class DummyConnection:
    """ implements enough of a connection to allow for
        removing of the cross database reference """
    def __init__(self):
        self.connections = []
        self._cache = {}

    def get(self, key):
        return None

    def open(self, **kw):
        return DummyConnection()

base_conn._db.databases['site1'] = DummyConnection()

app._objects = tuple([i for i in app._objects if i['id'] != 'badID'])

transaction.get().commit()

It's quite the hack, but allowed us to get the database back.

Brian Brinegar
Web Services Coordinator
Engineering Computer Network
-- 
Brian Brinegar
Web Services Coordinator
Engineering Computer Network


More information about the Zope mailing list