Project

General

Profile

« Previous | Next » 

Revision 172

db_xml.py: Use pointer target's name as pointer type where possible. Emphasize that pointer type determined from the pointer name itself is a guess based on common database conventions.

View differences:

db_xml.py
14 14

  
15 15
def is_ptr(node_name): return node_name.lower().endswith(ptr_suffix)
16 16

  
17
def ptr_type(node_name):
17
def ptr_type_guess(node_name):
18 18
    assert is_ptr(node_name)
19 19
    return node_name[:-len(ptr_suffix)]
20 20

  
......
29 29
            for child in xml_dom.NodeElemIter(parent):
30 30
                child_name = name_of(child)
31 31
                if is_ptr(child_name):
32
                    if ptr_type(child_name) == name: return ptr_target(child)
32
                    target = ptr_target(child)
33
                    if target.tagName == name: return target
33 34
                elif child_name == name: return child
34 35
    return None
35 36

  
......
91 92
            if try_num > 0: raise # exception still raised after retry
92 93
            if store_ids and is_ptr(ex.col):
93 94
                # Search for required column in ancestors and their children
94
                target = find_by_name(node, ptr_type(ex.col))
95
                target = find_by_name(node, ptr_type_guess(ex.col))
95 96
                if target == None: raise
96 97
                row[ex.col] = xml_dom.get_id(target)
97 98
            else: raise

Also available in: Unified diff