app/soc/views/models/base.py
changeset 2002 7698408e10a5
parent 1991 3aeda3007467
child 2021 3ab5d0d73f38
--- a/app/soc/views/models/base.py	Tue Mar 24 16:21:36 2009 +0000
+++ b/app/soc/views/models/base.py	Tue Mar 24 18:00:46 2009 +0000
@@ -25,6 +25,7 @@
 
 
 import csv
+import datetime
 import StringIO
 
 from google.appengine.ext import db
@@ -755,14 +756,18 @@
       # encode the data to UTF-8 to ensure compatibiliy
       for row_dict in data:
         for key in row_dict.keys():
-          row_dict[key] = row_dict[key].encode("utf-8")
+          value = row_dict[key]
+          row_dict[key] = value.encode("utf-8") if isinstance(value, basestring) else str(value)
         writer.writerow(row_dict)
     else:
       writer = csv.writer(f, dialect='excel')
 
       # encode the data to UTF-8 to ensure compatibiliy
       for row in data:
-        writer.writerow(row.encode("utf-8"))
+        if row:
+          writer.writerow(row.encode("utf-8"))
+        else:
+          writer.writerow(row)
 
     data = f.getvalue()