Revision 3649
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/db_xml.py | ||
---|---|---|
63 | 63 |
|
64 | 64 |
def put(db, node, row_ct_ref=None, on_error=exc.raise_, pool=None, |
65 | 65 |
store_ids=False, parent_id=None): |
66 |
return _put_table_part(db, node, None, row_ct_ref, on_error)
|
|
66 |
return _put_table_part(db, node, row_ct_ref, on_error) |
|
67 | 67 |
|
68 | 68 |
class ColRef: |
69 | 69 |
'''A reference to a table column''' |
... | ... | |
98 | 98 |
|
99 | 99 |
# Import col_defaults |
100 | 100 |
for col, node_ in col_defaults.items(): |
101 |
col_defaults[col] = _put_table_part(db, node_, None, row_ins_ct_ref, |
|
102 |
on_error) |
|
101 |
col_defaults[col] = _put_table_part(db, node_, row_ins_ct_ref, on_error) |
|
103 | 102 |
|
104 | 103 |
# Subset and partition in_table |
105 | 104 |
# OK to do even if table already the right size because it takes <1 sec. |
... | ... | |
127 | 126 |
if this_ct == 0: break # in_table size is multiple of partition_size |
128 | 127 |
|
129 | 128 |
# Recurse |
130 |
pkeys_loc = _put_table_part(db, node, in_table, row_ins_ct_ref,
|
|
131 |
on_error, col_defaults)
|
|
129 |
pkeys_loc = _put_table_part(db, node, row_ins_ct_ref, on_error,
|
|
130 |
col_defaults, in_table)
|
|
132 | 131 |
if in_row_ct_ref != None: in_row_ct_ref[0] += this_ct |
133 | 132 |
|
134 | 133 |
sql.empty_temp(db, in_table) |
... | ... | |
140 | 139 |
|
141 | 140 |
return pkeys_loc |
142 | 141 |
|
143 |
def _put_table_part(db, node, in_table=None, row_ins_ct_ref=None,
|
|
144 |
on_error=exc.raise_, col_defaults={}, parent_ids_loc=None, next=None):
|
|
142 |
def _put_table_part(db, node, row_ins_ct_ref=None, on_error=exc.raise_,
|
|
143 |
col_defaults={}, in_table=None, parent_ids_loc=None, next=None):
|
|
145 | 144 |
'''Helper function for put_table() only; should not be called directly''' |
146 | 145 |
def put_table_(node, in_row_ct_ref=None): |
147 |
return _put_table_part(db, node, in_table, row_ins_ct_ref, on_error,
|
|
148 |
col_defaults, parent_ids_loc, next)
|
|
146 |
return _put_table_part(db, node, row_ins_ct_ref, on_error, col_defaults,
|
|
147 |
in_table, parent_ids_loc, next)
|
|
149 | 148 |
|
150 | 149 |
def on_error_(e): |
151 | 150 |
exc.add_msg(e, 'node:\n'+str(node)) |
Also available in: Unified diff
db_xml.py: _put_table_part(): Reordered params to match put(), so that it can eventually be substituted for it