changeset 268:7aa24643e358

json almost working
author catherine@dellzilla
date Wed, 18 Mar 2009 09:28:21 -0400
parents 95195ec92c6c
children e4869b369e12
files sqlpython/output_templates.py
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/output_templates.py	Tue Mar 17 17:23:18 2009 -0400
+++ b/sqlpython/output_templates.py	Wed Mar 18 09:28:21 2009 -0400
@@ -14,14 +14,22 @@
   </${tblname}_resultset>
 </xml>"""),
 
+
 '\\j': genshi.template.NewTextTemplate("""
-{"${tblname}_resultset": [{% for row in rows %}
-    {${','.join('"%s": "%s"\\n    ' % (colname, itm) for (colname, itm) in zip(colnames, row))}
-    }
-    {% end %}\
+{"${tblname}_resultset": [
+    ${',\\n   '.join('{%s}' % (
+    ','.join('"%s": "%s"\\n    ' % ((colname, itm) for (colname, itm) in zip(colnames, row))) 
+    for row in rows))}
     ]
 }"""),  
 
+'\\j': genshi.template.NewTextTemplate("""
+{"${tblname}_resultset": [
+${',\\n'.join('        {%s}' % ', '.join('"%s": %s' % (colname,'"%s"' % itm) for (colname, itm) in zip(colnames, row)) for row in rows)}
+    ]
+}"""),  
+
+
 '\\h': genshi.template.MarkupTemplate("""
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns:py="http://genshi.edgewall.org/" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">