Project

General

Profile

« Previous | Next » 

Revision 2113

db_xml.py: put_table(): Fixed bug where relational functions were not being treated as value nodes, and thus their containing child was treated as a child with a backwards pointer instead of a field

View differences:

lib/db_xml.py
9 9
import strings
10 10
import util
11 11
import xml_dom
12
import xml_func
12 13

  
13 14
def name_of(node): return re.sub(r'^.*\.', r'', node.tagName)
14 15

  
15 16
ptr_suffix = '_id'
16 17

  
17
def value(node): return xml_dom.first_elem(node)
18

  
19 18
def is_ptr(node_name): return node_name.lower().endswith(ptr_suffix)
20 19

  
21 20
def ptr_type_guess(node_name):
......
24 23

  
25 24
def ptr_target(node):
26 25
    assert is_ptr(name_of(node))
27
    return value(node)
26
    return xml_dom.value_node(node)
28 27

  
29 28
def find_by_name(node, name):
30 29
    for parent in xml_dom.NodeParentIter(node):
......
155 154
        if xml_dom.is_empty(child): row[child_name] = None
156 155
        elif xml_dom.is_text(child):
157 156
            row[child_name] = strings.to_unicode(xml_dom.value(child))
158
        elif is_ptr(child_name):
159
            table, row[child_name] = put_table_(ptr_target(child))
160
            in_tables.append(table)
161
        else: children.append(child)
157
        else:
158
            child_value = xml_dom.value_node(child)
159
            if is_ptr(child_name) or xml_func.is_func(child_value):
160
                table, row[child_name] = put_table_(child_value)
161
                in_tables.append(table)
162
            else: children.append(child)
162 163
    try: del row[pkey_]
163 164
    except KeyError: pass
164 165
    

Also available in: Unified diff