Project

General

Profile

« Previous | Next » 

Revision 3650

db_xml.py: Renamed _put_table_part() to put(), replacing the existing put() whose functionality it now performs

View differences:

lib/db_xml.py
61 61
    
62 62
    return sql.select(db, table, fields, conds, limit, start)
63 63

  
64
def put(db, node, row_ct_ref=None, on_error=exc.raise_, pool=None,
65
    store_ids=False, parent_id=None):
66
    return _put_table_part(db, node, row_ct_ref, on_error)
67

  
68 64
class ColRef:
69 65
    '''A reference to a table column'''
70 66
    def __init__(self, name, idx):
......
98 94
    
99 95
    # Import col_defaults
100 96
    for col, node_ in col_defaults.items():
101
        col_defaults[col] = _put_table_part(db, node_, row_ins_ct_ref, on_error)
97
        col_defaults[col] = put(db, node_, row_ins_ct_ref, on_error)
102 98
    
103 99
    # Subset and partition in_table
104 100
    # OK to do even if table already the right size because it takes <1 sec.
......
126 122
        if this_ct == 0: break # in_table size is multiple of partition_size
127 123
        
128 124
        # Recurse
129
        pkeys_loc = _put_table_part(db, node, row_ins_ct_ref, on_error,
125
        pkeys_loc = put(db, node, row_ins_ct_ref, on_error,
130 126
            col_defaults, in_table)
131 127
        if in_row_ct_ref != None: in_row_ct_ref[0] += this_ct
132 128
        
......
139 135
    
140 136
    return pkeys_loc
141 137

  
142
def _put_table_part(db, node, row_ins_ct_ref=None, on_error=exc.raise_,
138
def put(db, node, row_ins_ct_ref=None, on_error=exc.raise_,
143 139
    col_defaults={}, in_table=None, parent_ids_loc=None, next=None):
144
    '''Helper function for put_table() only; should not be called directly'''
145
    def put_table_(node, in_row_ct_ref=None):
146
        return _put_table_part(db, node, row_ins_ct_ref, on_error, col_defaults,
140
    def put_(node, in_row_ct_ref=None):
141
        return put(db, node, row_ins_ct_ref, on_error, col_defaults,
147 142
            in_table, parent_ids_loc, next)
148 143
    
149 144
    def on_error_(e):
......
172 167
        # Parse args
173 168
        def wrap_e(e): raise xml_func.SyntaxError(e)
174 169
        try:
175
            next = row['next'] # modifies outer next var used by put_table_()
170
            next = row['next'] # modifies outer next var used by put_()
176 171
            require = row['require']
177 172
            path = row['path']
178 173
        except KeyError, e: wrap_e(e)
......
181 176
        try: next = next[0].name
182 177
        except IndexError, e: wrap_e(e)
183 178
        
184
        return put_table_(path)
179
        return put_(path)
185 180
    
186 181
    in_tables = []
187 182
    no_empty = set()
......
203 198
    parent_ids_loc = None # applies to this section
204 199
    for out_col, value in row.iteritems():
205 200
        # Handle forward pointers
206
        if xml_dom.is_node(value): row[out_col] = value = put_table_(value)
201
        if xml_dom.is_node(value): row[out_col] = value = put_(value)
207 202
        
208 203
        # Translate values
209 204
        if isinstance(value, sql_gen.Col): # value is temp table column
......
223 218
    
224 219
    # Insert children with fkeys to parent
225 220
    parent_ids_loc = pkeys_loc # applies to this section
226
    for child in children: put_table_(child)
221
    for child in children: put_(child)
227 222
    
228 223
    return pkeys_loc

Also available in: Unified diff