Thu, 28 Jun 2018 11:19:14 +0200 [py3] Avoid setting attribute on Element instance in wdoc view 3.26
Denis Laxalde <denis.laxalde@logilab.fr> [Thu, 28 Jun 2018 11:19:14 +0200] rev 12336
[py3] Avoid setting attribute on Element instance in wdoc view This change is needed to make "wdoc" view work on Python 3. Indeed, before this patch, we used to set a "parent" attribute on Element instances, which is not permitted since Python 3.3 as xml.etree.ElementTree uses the C implementation by default. To get rid of this "parent" attribute, we rework the XML nodes processing logic to return and retrieve a node along with its parent in several place of the code. Namely, build_toc_index() now accepts the "parent" value for "node" and inserts it in the "index" dict (thus avoid `node.parent = <value>`). Respectively, every query to the "index" dict is updated to also retrieve the "parent" (thus avoiding `<value> = node.parent`). Later in InlineHelpView class, the "index" dict is bound to "tocindex" attribute so we adjust how it is queried in respective methods. Tests cubicweb/web/test/unittest_views_wdoc.py now pass on Python 3.
(0) -10000 -3000 -1000 -300 -100 -30 -10 -1 +1 +10 +30 +100 +300 tip