Simplify retrieval of archive unit's content sequence in itree adapter
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 25 Aug 2016 17:27:58 +0200
changeset 1555 d1c4f5a8fc8a
parent 1554 dce90c3bd6f4
child 1556 347aa6ee8338
Simplify retrieval of archive unit's content sequence in itree adapter
entities/itree.py
--- a/entities/itree.py	Thu Aug 25 16:56:08 2016 +0200
+++ b/entities/itree.py	Thu Aug 25 17:27:58 2016 +0200
@@ -79,14 +79,11 @@
             return parent
         return parent_archive_unit(parent)
 
-    def iterchildren(self, entities=True, sametype=False):
-        choice = self.entity.related('seda_alt_archive_unit_archive_unit_ref_id', 'subject').one()
-        seq_rset = choice.related('seda_seq_alt_archive_unit_archive_unit_ref_id_management',
-                                  'subject')
-        if not seq_rset:
+    def iterchildren(self):
+        seq = self.entity.first_level_choice.content_sequence
+        if seq is None:
             # 'reference' archive unit
             return
-        seq = seq_rset.one()
         for rel, role in [('seda_content', 'object'), ('seda_archive_unit', 'object')]:
             for child in seq.related(rel, role, entities=True):
                 yield child