Remove remaining usage of dropped 'id' attributes
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 11 Jan 2017 22:03:06 +0100
changeset 2297 ff04117be4a2
parent 2296 5f607c9702cb
child 2298 999e4cf6efe9
Remove remaining usage of dropped 'id' attributes Update rql query and use .dc_title entity method to generate label from annotation (prefetched).
views/archiveunit.py
--- a/views/archiveunit.py	Wed Jan 11 09:06:18 2017 +0100
+++ b/views/archiveunit.py	Wed Jan 11 22:03:06 2017 +0100
@@ -78,10 +78,10 @@
     req = form._cw
     parent, container = parent_and_container(form.edited_entity)
     assert container is not None
-    rset = req.execute('Any XID, X ORDERBY XID WHERE '
-                       'X is SEDAArchiveUnit, X id XID, X container R, R eid %(root)s',
+    rset = req.execute('Any X, XUA ORDERBY XUA WHERE '
+                       'X is SEDAArchiveUnit, X user_annotation XUA, X container R, R eid %(root)s',
                        {'root': container.eid})
-    return [(label, str(eid)) for label, eid in rset]
+    return [(entity.dc_title(), str(entity.eid)) for entity in rset.entities()]
 
 
 affk.tag_subject_of(('SEDAArchiveUnitRefId', 'seda_archive_unit_ref_id_to', '*'),
@@ -95,11 +95,11 @@
     req = form._cw
     parent, container = parent_and_container(form.edited_entity)
     assert container is not None
-    rset = req.execute('Any XID, X ORDERBY XID WHERE '
-                       'X is IN(SEDABinaryDataObject, SEDAPhysicalDataObject), X id XID, '
-                       'X container R, R eid %(root)s',
+    rset = req.execute('Any X, XUA ORDERBY XUA WHERE '
+                       'X is IN(SEDABinaryDataObject, SEDAPhysicalDataObject), '
+                       ', X user_annotation XUAX container R, R eid %(root)s',
                        {'root': container.eid})
-    return [(label, str(eid)) for label, eid in rset]
+    return [(entity.dc_title(), str(entity.eid)) for entity in rset.entities()]
 
 
 for rtype in ('seda_data_object_reference_id', 'seda_target'):
@@ -444,8 +444,8 @@
 
     def display_subobjects_list(self, entity):
         rset = self._cw.execute(
-            'Any DO, DOID, DOUC ORDERBY DOID WHERE '
-            'DO id DOID, DO user_cardinality DOUC, '
+            'Any DO, DOUA, DOUC ORDERBY DOUA WHERE '
+            'DO user_annotation DOUA, DO user_cardinality DOUC, '
             'REF seda_data_object_reference_id DO, REF seda_data_object_reference SEQ, '
             'SEQ eid %(x)s', {'x': entity.eid})
         if rset: