Project

General

Profile

« Previous | Next » 

Revision 2506

db_xml.py: Added internal next param used by simplifyPath. put_table(): Refactored to use outer parent_ids_loc var and modify that as needed rather than having to pass parent_ids_loc as a param to put_table_().

View differences:

lib/db_xml.py
138 138
input_col_prefix = '$'
139 139

  
140 140
def put_table(db, node, in_table, commit=False, in_row_ct_ref=None,
141
    row_ins_ct_ref=None, limit=None, start=0, parent_ids_loc=None):
141
    row_ins_ct_ref=None, limit=None, start=0, parent_ids_loc=None, next=None):
142 142
    '''
143 143
    @param node The XML tree that transforms the input to the output. Similar to
144 144
        put()'s node param, but with the input column name prefixed by
......
158 158
    
159 159
    def pkey(table): return sql.pkey(db, table, True)
160 160
    
161
    def put_table_(node, parent_ids_loc=None):
162
        return put_table(db, node, in_table, commit,
163
            row_ins_ct_ref=row_ins_ct_ref, parent_ids_loc=parent_ids_loc)
161
    def put_table_(node):
162
        return put_table(db, node, in_table, commit, None, row_ins_ct_ref,
163
            parent_ids_loc=parent_ids_loc, next=next)
164 164
    
165 165
    out_table = name_of(node)
166 166
    special_funcs = set(['_simplifyPath'])
......
185 185
        # Parse args
186 186
        def wrap_e(e): raise xml_func.SyntaxError(e)
187 187
        try:
188
            next = row['next']
188
            next = row['next'] # modifies outer next var used by put_table_()
189 189
            require = row['require']
190 190
            path = row['path']
191 191
        except KeyError, e: wrap_e(e)
......
195 195
        except IndexError, e: wrap_e(e)
196 196
        
197 197
        # For now, just skip XML func
198
        return put_table_(path, parent_ids_loc)
198
        return put_table_(path)
199 199
    
200 200
    # Remove any explicit pkey
201 201
    try: del row[pkey(out_table)]
......
208 208
        row[parent_ptr] = parent_ids_loc
209 209
    
210 210
    # Divide fields into input columns and literal values
211
    parent_ids_loc = None # applies to this section
211 212
    in_tables = [in_table]
212 213
    for out_col, value in row.iteritems():
213 214
        # Handle forward pointers
......
230 231
    if commit: db.db.commit()
231 232
    
232 233
    # Insert children with fkeys to parent
233
    for child in children: put_table_(child, pkeys_loc)
234
    parent_ids_loc = pkeys_loc # applies to this section
235
    for child in children: put_table_(child)
234 236
    
235 237
    # Count # rows and update in_row_ct_ref once all columns have been processed
236 238
    if in_row_ct_ref != None:

Also available in: Unified diff