Revision 135
Added by Aaron Marcuse-Kubitza about 13 years ago
db_xml.py | ||
---|---|---|
37 | 37 |
if pkeys == None: pkeys = {} |
38 | 38 |
def pkey(table): return sql.pkey(db, pkeys, table) |
39 | 39 |
|
40 |
table = name_of(node) |
|
41 |
pkey_ = pkey(table) |
|
42 |
|
|
43 |
fields = [] |
|
44 |
conds = {} |
|
40 | 45 |
for child in xml_dom.NodeElemIter(node): |
41 |
assert xml_dom.is_text(child) |
|
46 |
child_name = name_of(child) |
|
47 |
if xml_dom.is_empty(child): fields.append(child_name) |
|
48 |
elif xml_dom.is_text(child): conds[child_name] = xml_dom.value(child) |
|
49 |
else: raise Exception('Joins not supported yet') |
|
50 |
id_ = xml_dom.get_id(node) |
|
51 |
if id_ != '': conds[pkey(table)] = id_ # replace any existing pkey value |
|
52 |
if fields == []: fields.append(pkey_) |
|
42 | 53 |
|
43 |
return []
|
|
54 |
return sql.select(db, table, fields, conds)
|
|
44 | 55 |
|
45 | 56 |
def put(db, node, store_ids=False, row_ct_ref=None, pkeys=None, parent_id=None): |
46 | 57 |
# store_ids enables searching the tree for missing fields |
Also available in: Unified diff
map: Implemented DB input support for querying a single table