Revision 1864
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/db_xml.py | ||
---|---|---|
56 | 56 |
|
57 | 57 |
return sql.select(db, table, fields, conds, limit, start) |
58 | 58 |
|
59 |
def put(db, node, row_ct_ref=None, on_error=exc.raise_, store_ids=False,
|
|
60 |
parent_id=None): |
|
59 |
def put(db, node, row_ct_ref=None, on_error=exc.raise_, pool=None,
|
|
60 |
store_ids=False, parent_id=None):
|
|
61 | 61 |
'''store_ids enables searching the tree for missing fields''' |
62 | 62 |
def pkey(table): return sql.pkey(db, table, True) |
63 | 63 |
|
64 | 64 |
def put_(node, parent_id=None): |
65 |
return put(db, node, row_ct_ref, on_error, store_ids, parent_id) |
|
65 |
return put(db, node, row_ct_ref, on_error, pool, store_ids, parent_id)
|
|
66 | 66 |
|
67 | 67 |
def on_error_(e): |
68 | 68 |
exc.add_msg(e, 'node:\n'+str(node)) |
... | ... | |
109 | 109 |
else: raise |
110 | 110 |
except sql.DatabaseErrors, e: on_error_(e); return None |
111 | 111 |
|
112 |
def put_child(node, parent_id): |
|
113 |
call = lambda: put_(node, parent_id) |
|
114 |
if pool != None: pool.apply_async(call) |
|
115 |
else: call() |
|
116 |
|
|
112 | 117 |
# Insert children with fkeys to parent |
113 |
for child in children: put_(child, id_) |
|
118 |
for child in children: put_child(child, id_)
|
|
114 | 119 |
|
115 | 120 |
return id_ |
Also available in: Unified diff
db_xml.py: put(): Added parallel processing support for inserting children with fkeys to parent asynchronously