dabo Commit
Revision 5158
Date: 2009-03-30 14:22:19 -0700 (Mon, 30 Mar 2009)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5158
Changed:
U trunk/dabo/lib/reportUtils.py
U trunk/dabo/lib/xmltodict.py
Log:
Attempt to fix reportUtils.getTestCursorXmlFromDataSet() function.
I elected not to step on potential backwards compatibility after discovering
that we work around a wx quirk from outside the wx domain (dealing with the
double ampersands).
Diff:
Modified: trunk/dabo/lib/reportUtils.py
===================================================================
--- trunk/dabo/lib/reportUtils.py 2009-03-27 23:24:58 UTC (rev 5157)
+++ trunk/dabo/lib/reportUtils.py 2009-03-30 21:22:19 UTC (rev 5158)
@@ -69,6 +69,7 @@
def getTestCursorXmlFromDataSet(dataset):
"""Returns the xml for insertion into a .rfxml file from a dataset."""
+ from dabo.lib.xmltodict import escape
assert len(dataset) > 0
@@ -93,9 +94,17 @@
if isinstance(v, basestring):
v = v.replace("'", "")
v = repr(v)
+ v = escape(v, escapeAmp=False)
v = v.replace('"', "'")
xml += """%s="%s" """ % (k, v)
xml += """ />\n"""
xml += """\t</testcursor>\n"""
return xml
+
+
+if __name__ == "__main__":
+ ds = [{"name": "Paul McNett"},
+ {"name": "A & B Motors"},
+ {"name": '9" Nails'}]
+ print getTestCursorXmlFromDataSet(ds)
Modified: trunk/dabo/lib/xmltodict.py
===================================================================
--- trunk/dabo/lib/xmltodict.py 2009-03-27 23:24:58 UTC (rev 5157)
+++ trunk/dabo/lib/xmltodict.py 2009-03-30 21:22:19 UTC (rev 5158)
@@ -239,11 +239,14 @@
return "%s%s%s" % (qt, val, qt)
-def escape(val):
+def escape(val, escapeAmp=True):
"""Escape any characters that cannot be stored directly in XML."""
# First escape internal ampersands. We need to double them up due to a
# quirk in wxPython and the way it displays this character.
- val = val.replace("&", "&&")
+ if escapeAmp:
+ val = val.replace("&", "&&")
+ else:
+ val = val.replace("&", "&")
# Escape any internal quotes
val = val.replace('"', '"').replace("'", "'")
# Escape any high-order characters
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]