def getObjectPath(obj, tid): path = [] seen_root = False state = ZodbObjectState(obj, tid) while True: if state.isRoot(): path.append('/') seen_root = True else: if path: path.append('/') if not state.getName() and state.getParentState() is None: # not using hex() because we don't want L suffixes for # 64-bit values path.append('0x%x' % state.getObjectId()) break path.append(state.getName() or '???') state = state.getParentState() if state is None: if not seen_root: path.append('/') path.append('...') path.append('/') break return ''.join(path[::-1])
def testParentState(self): state = ZodbObjectState(self.child).getParentState() self.assertTrue(state.isRoot())