Пример #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])
Пример #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])
Пример #3
0
 def testZodbObjectState(self):
     state = ZodbObjectState(self.obj)
     self.assertEquals(state.listItems(), None)
     self.assertTrue(state.listAttributes()[0][0], '_SampleContainer__data')
     self.assertEquals(state.getParent(), None)
     self.assertEquals(state.getName(), None)
     self.assertTrue('_SampleContainer__data' in state.asDict().keys())
Пример #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())
Пример #5
0
 def testNameResiliency(self):
     obj = self.conn.root()['obj'] = SeriouslyBrokenName()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertEqual(state.getName(), None)
Пример #6
0
 def testNameFromClassAttribute(self):
     state = ZodbObjectState(self.named_obj)
     self.assertEqual(state.getName(), 'sample_folder')
Пример #7
0
 def testNameFromClassAttribute(self):
     state = ZodbObjectState(self.named_obj)
     self.assertEquals(state.getName(), 'sample_folder')
Пример #8
0
 def testNameResiliency(self):
     obj = self.conn.root()['obj'] = SeriouslyBrokenName()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertEqual(state.getName(), None)