Esempio n. 1
0
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])
Esempio n. 2
0
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])
Esempio n. 3
0
 def testZodbObjectState(self):
     state = ZodbObjectState(self.obj)
     self.assertEqual(state.getError(), None)
     self.assertEqual(state.listItems(), None)
     self.assertEqual(
         list(state.listAttributes())[0][0], '_SampleContainer__data')
     self.assertEqual(state.getParent(), None)
     self.assertEqual(state.getParentState(), None)
     self.assertEqual(state.getName(), None)
     self.assertTrue('_SampleContainer__data' in state.asDict().keys())
Esempio n. 4
0
 def testZodbObjectState(self):
     state = ZodbObjectState(self.obj)
     self.assertEqual(state.getError(), None)
     self.assertEqual(state.listItems(), None)
     self.assertEqual(list(state.listAttributes())[0][0],
                      '_SampleContainer__data')
     self.assertEqual(state.getParent(), None)
     self.assertEqual(state.getParentState(), None)
     self.assertEqual(state.getName(), None)
     self.assertTrue('_SampleContainer__data' in state.asDict().keys())