rebuild(modulename, globalname, *args)
Recreate a broken object, possibly recreating the missing class
This functions unpickles broken objects:
>>> broken = rebuild('ZODB.notthere', 'atall', 1, 2) >>> broken <broken ZODB.notthere.atall instance> >>> broken.__Broken_newargs__ (1, 2)
If we "repair" the brokenness:
>>> class notthere: # fake notthere module ... class atall(object): ... def __new__(self, *args): ... ob = object.__new__(self) ... ob.args = args ... return ob ... def __repr__(self): ... return 'atall %s %s' % self.args >>> sys.modules['ZODB.notthere'] = notthere >>> rebuild('ZODB.notthere', 'atall', 1, 2) atall 1 2 >>> del sys.modules['ZODB.notthere']
Cleanup:
>>> broken_cache.clear()