diff sqlpyPlus.py @ 105:1e69f3a26216

fixed python2.4 compat
author catherine@localhost
date Mon, 09 Jun 2008 12:34:06 -0400
parents 2619e81c5772
children 31de4c0b06ee
line wrap: on
line diff
--- a/sqlpyPlus.py	Mon Jun 09 12:14:16 2008 -0400
+++ b/sqlpyPlus.py	Mon Jun 09 12:34:06 2008 -0400
@@ -393,6 +393,10 @@
         if needsquotes:
             return "'%s'" % str(itm)
         return str(itm)
+    def str_or_empty(self, itm):
+        if itm is None:
+            return ''
+        return str(itm)
     def output_as_insert_statements(self):
         usequotes = [d[1] != cx_Oracle.NUMBER for d in self.curs.description]
         def formatRow(row):
@@ -405,7 +409,7 @@
 
     def output_row_as_xml(self, row):
         result = ['  <%s>\n    %s\n  </%s>' %
-                  (colname.lower(), str('' if (itm is None) else itm), colname.lower()) 
+                  (colname.lower(), self.str_or_empty(itm), colname.lower()) 
                   for (itm, colname) in zip(row, self.colnames)]
         return '\n'.join(result)        
     def output_as_xml(self):
@@ -420,7 +424,7 @@
         for row in self.rows:
             result.append('  <tr>\n    %s\n  </tr>' %
                           (''.join('<td>%s</td>' %
-                                   str('' if (itm is None) else itm)
+                                   self.str_or_empty(itm)
                                    for itm in row)))                
         result = '''<table id="%s">
 %s