Project

General

Profile

« Previous | Next » 

Revision 2005

db_xml.py: put_table(): Added part of put() code that should be common to both functions

View differences:

lib/db_xml.py
116 116
    
117 117
    return id_
118 118

  
119
def put_table(db, node, table, commit=False, row_ct_ref=None,
119
def put_table(db, node, in_table, commit=False, row_ct_ref=None,
120 120
    table_is_esc=False):
121 121
    '''
122 122
    @param node The XML tree that transforms the input to the output. Similar to
......
124 124
        place of the column value.
125 125
    @param commit Whether to commit after each query
126 126
    '''
127
    def pkey(table): return sql.pkey(db, table, True)
128
    
129
    out_table = name_of(node)
130
    pkey_ = pkey(out_table)
131
    row = {}
132
    children = []
133
    
134
    # Divide children into fields and children with fkeys to parent
135
    for child in xml_dom.NodeElemIter(node):
136
        child_name = name_of(child)
137
        if xml_dom.is_empty(child): row[child_name] = None
138
        elif xml_dom.is_text(child):
139
            row[child_name] = strings.to_unicode(xml_dom.value(child))
140
        elif is_ptr(child_name): pass#row[child_name] = put_(ptr_target(child))
141
        else: children.append(child)
142
    try: del row[pkey_]
143
    except KeyError: pass
144
    
127 145
    import sys; sys.stderr.write(str(node))
128 146
    if commit: db.db.commit()
129 147
    raise NotImplementedError('By-column optimization not available yet')

Also available in: Unified diff