#47 Fix for the overwritting of document attributes

closed-fixed
nobody
None
5
2013-01-21
2009-03-26
No

This patch addresses the issue expressed in # 2714848 by added a series of helper functions and test cases to nodes.Element which handle the merger of two element attribute lists and then apply this to the TitlePromoter transformation class. Test cases are provided for all new code which is broken in the the following logical groups:

1) Renamed the dict variable to dict_ to avoid confusion.
2) Add new Element class tuples to store the basic attributes, the list attributes, the recognized or know attributes and the local, not-to-be-transferred attributes and class methods to retrieve each.
3) update_all_atts: merges the attributes stored in dict_ with self in one of 4 ways and with favouring either self or dict_ in conflict and also allows the overriding the 'source' attribute of self. The four methods of replacement are as follows

a) Consistent - Depending on which is favoured, when a conflict occurs the value is set to the favoured side.
b) Concatenate - If the types for a given attribute in both self and dict_ are both list type, extend self's list to include those of dict_
c) Coerce - If one of the types for a given attribute is list type, convert both to list type if not already by making lists of 1 element and extend self's list to include those of dict_
d) Convert - For a given attribute in both self and dict_, conver both to list type if not already by making lists of 1 element and extend self's list to include those of dict_

4) Changed TitlePromoter.promote_title and TitlePromoter.promote_subtitle to call update_all_atts_concatenating instead of .attributes.update to transfer attributes from one node to another.
5) Added test cases for these changes

Discussion

  • This patch added support for proper attribute merging

     
  • Günter Milde
    Günter Milde
    2013-01-21

    Applied, thanks for the patch.

     
  • Günter Milde
    Günter Milde
    2013-01-21

    • status: open --> closed-fixed