Beispiel #1
0
    def __iter__(self):

        for item in self.previous:

            pathkey = self.pathkey(*item.keys())[0]
            uidkey = self.uidkey(*item.keys())[0]

            if not pathkey or not uidkey:  # not enough info
                yield item
                continue

            path = item[pathkey]
            uid = item[uidkey]

            obj = traverse(self.context, str(path).lstrip('/'), None)
            if obj is None:  # path doesn't exist
                yield item
                continue

            if IReferenceable.providedBy(obj):
                oldUID = obj.UID()
                if oldUID != uid:
                    if not oldUID:
                        setattr(obj, UUID_ATTR, uid)
                    else:
                        obj._setUID(uid)

            if IAttributeUUID.providedBy(obj):
                IMutableUUID(obj).set(uid)

            yield item
Beispiel #2
0
def addUUIDOnPortal(portal):
    if not IAttributeUUID.providedBy(portal):
        alsoProvides(portal, IAttributeUUID)
    uuid_adapter = IMutableUUID(portal)
    if uuid_adapter.get() is None:
        generator = getUtility(IUUIDGenerator)
        uuid = generator()
        uuid_adapter.set(uuid)
Beispiel #3
0
def mirror_aware_attribute_uuid(context):
    if not IAttributeUUID.providedBy(context):
        raise TypeError(f'Cannot determine a UUID for {context}.')
    if mirror := mirror_info(context).mirror:
        return uuid_at_mirror(context, mirror)
Beispiel #4
0
 def test_is_referenceable(self):
     self.assertTrue(IReferenceable.providedBy(self.department))
     self.assertTrue(IAttributeUUID.providedBy(self.department))
 def test_is_referenceable(self):
     self.folder.invokeFactory('telesur.contenttypes.program', 'p1')
     p1 = self.folder['p1']
     self.assertTrue(IReferenceable.providedBy(p1))
     self.assertTrue(IAttributeUUID.providedBy(p1))
 def test_is_referenceable(self):
     self.assertTrue(IReferenceable.providedBy(self.agendadiaria))
     self.assertTrue(IAttributeUUID.providedBy(self.agendadiaria))
Beispiel #7
0
 def test_is_referenceable(self):
     self.assertTrue(IReferenceable.providedBy(self.legislature))
     self.assertTrue(IAttributeUUID.providedBy(self.legislature))
 def test_is_referenceable(self):
     self.assertTrue(IReferenceable.providedBy(self.parliamentarian))
     self.assertTrue(IAttributeUUID.providedBy(self.parliamentarian))
Beispiel #9
0
 def test_is_referenceable(self):
     self.assertTrue(IReferenceable.providedBy(self.example))
     self.assertTrue(IAttributeUUID.providedBy(self.example))
Beispiel #10
0
 def test_is_referenceable(self):
     self.folder.invokeFactory('collective.polls.poll', 'p1')
     p1 = self.folder['p1']
     self.assertTrue(IReferenceable.providedBy(p1))
     self.assertTrue(IAttributeUUID.providedBy(p1))
 def test_is_referenceable(self):
     self.assertTrue(IReferenceable.providedBy(self.compromisso))
     self.assertTrue(IAttributeUUID.providedBy(self.compromisso))