summaryrefslogtreecommitdiffstats
path: root/server/xmlparser.py
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2009-07-30 14:39:23 +0200
committerDavid Sommerseth <davids@redhat.com>2009-07-30 14:39:23 +0200
commitab1389f9423764639424df40ca3bf083f50a7ca4 (patch)
treecf97ed00a5c8eabdbc659c5578c0a7273a230dd2 /server/xmlparser.py
parent7b5859d70135fe071b492b02558997e3f7286ba1 (diff)
downloadrteval-ab1389f9423764639424df40ca3bf083f50a7ca4.tar.gz
rteval-ab1389f9423764639424df40ca3bf083f50a7ca4.tar.xz
rteval-ab1389f9423764639424df40ca3bf083f50a7ca4.zip
xmlparser: Correctly format rterid and syskey arguments, added support for /sqlite/@key attribute
Diffstat (limited to 'server/xmlparser.py')
-rw-r--r--server/xmlparser.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/server/xmlparser.py b/server/xmlparser.py
index a476f49..8c4e2f2 100644
--- a/server/xmlparser.py
+++ b/server/xmlparser.py
@@ -48,6 +48,7 @@ class XMLSQLparser(object):
xsltdoc = self.__get_xml_data(xslt)
self.parser = libxslt.parseStylesheetDoc(xsltdoc)
+
def __get_xml_data(self, input):
if hasattr(input, '__module__') and (input.__module__ == 'libxml2') and hasattr(input, 'get_type'):
if input.get_type() == 'document_xml':
@@ -82,8 +83,8 @@ class XMLSQLparser(object):
def GetSQLdata(self, tbl, rterid=None, syskey=None):
params = { 'table': '"%s"' % tbl,
- 'rterid': rterid,
- 'syskey': syskey }
+ 'rterid': rterid and '"%i"' % rterid,
+ 'syskey': syskey and '"%i"' % syskey }
resdoc = self.parser.applyStylesheet(self.xml, params)
# Extract fields, and make sure they are ordered/sorted by the fid attribute
@@ -127,6 +128,15 @@ class XMLSQLparser(object):
result = { 'table': resdoc.xpathEval('/sqldata/@table')[0].content,
'fields': fields, 'records': records}
+
+ # Extract the key field being returned from INSERT statements, if set
+ try:
+ retkey = resdoc.xpathEval('/sqldata/@key')
+ if retkey and retkey[0] and retkey[0].content:
+ result['returning'] = retkey.content
+ except:
+ pass
+
resdoc.freeDoc()
return result