preventing invalid query when exporting a rows object, thanks Niphlod
This commit is contained in:
1 parent
3cd0b78edb
commit
515cc6b829
2 files changed
+30
-24
No files matched your search
@@ -1 +1 @@
|
|||||||
Version 2.3.2 (2012-12-17 17:13:45) dev
|
Version 2.3.2 (2012-12-18 09:21:46) dev
|
||||||
+29
-23
@@ -2851,15 +2851,16 @@ class ExporterTSV(ExportClass):
|
|||||||
final = cStringIO.StringIO()
|
final = cStringIO.StringIO()
|
||||||
import csv
|
import csv
|
||||||
writer = csv.writer(out, delimiter='\t')
|
writer = csv.writer(out, delimiter='\t')
|
||||||
import codecs
|
if self.rows:
|
||||||
final.write(codecs.BOM_UTF16)
|
import codecs
|
||||||
writer.writerow(
|
final.write(codecs.BOM_UTF16)
|
||||||
[unicode(col).encode("utf8") for col in self.rows.colnames])
|
writer.writerow(
|
||||||
data = out.getvalue().decode("utf8")
|
[unicode(col).encode("utf8") for col in self.rows.colnames])
|
||||||
data = data.encode("utf-16")
|
data = out.getvalue().decode("utf8")
|
||||||
data = data[2:]
|
data = data.encode("utf-16")
|
||||||
final.write(data)
|
data = data[2:]
|
||||||
out.truncate(0)
|
final.write(data)
|
||||||
|
out.truncate(0)
|
||||||
records = self.represented()
|
records = self.represented()
|
||||||
for row in records:
|
for row in records:
|
||||||
writer.writerow(
|
writer.writerow(
|
||||||
@@ -2881,7 +2882,10 @@ class ExporterCSV(ExportClass):
|
|||||||
ExportClass.__init__(self, rows)
|
ExportClass.__init__(self, rows)
|
||||||
|
|
||||||
def export(self):
|
def export(self):
|
||||||
return str(self.rows)
|
if self.rows:
|
||||||
|
return str(self.rows)
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class ExporterHTML(ExportClass):
|
class ExporterHTML(ExportClass):
|
||||||
@@ -2895,12 +2899,13 @@ class ExporterHTML(ExportClass):
|
|||||||
def export(self):
|
def export(self):
|
||||||
out = cStringIO.StringIO()
|
out = cStringIO.StringIO()
|
||||||
out.write('<html>\n<body>\n<table>\n')
|
out.write('<html>\n<body>\n<table>\n')
|
||||||
colnames = [a.split('.') for a in self.rows.colnames]
|
if self.rows:
|
||||||
for row in self.rows.records:
|
colnames = [a.split('.') for a in self.rows.colnames]
|
||||||
out.write('<tr>\n')
|
for row in self.rows.records:
|
||||||
for col in colnames:
|
out.write('<tr>\n')
|
||||||
out.write('<td>' + str(row[col[0]][col[1]]) + '</td>\n')
|
for col in colnames:
|
||||||
out.write('</tr>\n')
|
out.write('<td>' + str(row[col[0]][col[1]]) + '</td>\n')
|
||||||
|
out.write('</tr>\n')
|
||||||
out.write('</table>\n</body>\n</html>')
|
out.write('</table>\n</body>\n</html>')
|
||||||
return str(out.getvalue())
|
return str(out.getvalue())
|
||||||
|
|
||||||
@@ -2916,12 +2921,13 @@ class ExporterXML(ExportClass):
|
|||||||
def export(self):
|
def export(self):
|
||||||
out = cStringIO.StringIO()
|
out = cStringIO.StringIO()
|
||||||
out.write('<rows>\n')
|
out.write('<rows>\n')
|
||||||
colnames = [a.split('.') for a in self.rows.colnames]
|
if self.rows:
|
||||||
for row in self.rows.records:
|
colnames = [a.split('.') for a in self.rows.colnames]
|
||||||
out.write('<row>\n')
|
for row in self.rows.records:
|
||||||
for col in colnames:
|
out.write('<row>\n')
|
||||||
out.write(
|
for col in colnames:
|
||||||
'<%s>' % col + str(row[col[0]][col[1]]) + '</%s>\n' % col)
|
out.write(
|
||||||
out.write('</row>\n')
|
'<%s>' % col + str(row[col[0]][col[1]]) + '</%s>\n' % col)
|
||||||
|
out.write('</row>\n')
|
||||||
out.write('</rows>')
|
out.write('</rows>')
|
||||||
return str(out.getvalue())
|
return str(out.getvalue())
|
||||||
Reference in new issue
Block a user