dabo Commit
Revision 5167
Date: 2009-04-02 16:36:43 -0700 (Thu, 02 Apr 2009)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5167

Changed:
U   trunk/dabo/lib/reportUtils.py

Log:
Improved the XML formatting for the report testcursor: insert line breaks after
each field; camel-case the property name (it is case-insensitive in the report
writer, so it won't break anything).


Diff:
Modified: trunk/dabo/lib/reportUtils.py
===================================================================
--- trunk/dabo/lib/reportUtils.py       2009-04-02 19:46:02 UTC (rev 5166)
+++ trunk/dabo/lib/reportUtils.py       2009-04-02 23:36:43 UTC (rev 5167)
@@ -83,28 +83,29 @@
                        datetime.datetime: "datetime.datetime",
                        Decimal: "Decimal"}
 
-       xml = """\t<testcursor """
-       for k, v in dataset[0].items():
-               xml += """%s="%s" """ % (k, typemap.get(type(v)))
-       xml += """ >\n"""
+       xml = """\t<TestCursor\n"""
+       for k, v in sorted(dataset[0].items()):
+               xml += """\t\t%s = "%s"\n""" % (k, typemap.get(type(v)))
+       xml += """\t>\n\n"""
 
        for r in dataset:
-               xml += """\t\t<record """
-               for k, v in r.items():
+               xml += """\t\t<Record\n"""
+               for k, v in sorted(r.items()):
                        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\t\t%s = "%s"\n""" % (k, v)
+               xml += """\t\t/>\n"""
        
-       xml += """\t</testcursor>\n"""
+       xml += """\t</TestCursor>\n"""
        return xml
 
 
 if __name__ == "__main__":
        ds = [{"name": "Paul McNett"},
              {"name": "A & B Motors"},
-             {"name": '9" Nails'}]
+             {"name": '9" Nails'},
+             {"name": "<None>"}]
        print getTestCursorXmlFromDataSet(ds)



_______________________________________________
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]

Reply via email to