Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 1773)
+++ pykota/trunk/pykota/storages/sql.py (revision 1777)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.53  2004/10/05 09:59:20  jalet
+# Restore compatibility with Python 2.1
+#
 # Revision 1.52  2004/10/04 22:23:54  jalet
 # Charset conversions for dumps from the PostgreSQL backend
@@ -106,5 +109,5 @@
                     if type(field) == StringType :
                         try :
-                            fields[j] = field.decode("UTF-8").encode(self.tool.getCharset()) 
+                            fields[j] = unicode(field, "UTF-8").encode(self.tool.getCharset()) 
                         except UnicodeEncodeError : # takes care of old jobs in history not stored as UTF-8    
                             pass
@@ -212,5 +215,5 @@
             printer.PricePerJob = fields.get("priceperjob") or 0.0
             printer.PricePerPage = fields.get("priceperpage") or 0.0
-            printer.Description = (fields.get("description") or "").decode("UTF-8").encode(self.tool.getCharset()) 
+            printer.Description = unicode((fields.get("description") or ""), "UTF-8").encode(self.tool.getCharset()) 
             printer.Exists = 1
         return printer    
@@ -261,8 +264,8 @@
             lastjob.JobPrice = fields.get("jobprice")
             lastjob.JobAction = fields.get("action")
-            lastjob.JobFileName = (fields.get("filename") or "").decode("UTF-8").encode(self.tool.getCharset()) 
-            lastjob.JobTitle = (fields.get("title") or "").decode("UTF-8").encode(self.tool.getCharset()) 
+            lastjob.JobFileName = unicode((fields.get("filename") or ""), "UTF-8").encode(self.tool.getCharset()) 
+            lastjob.JobTitle = unicode((fields.get("title") or ""), "UTF-8").encode(self.tool.getCharset()) 
             lastjob.JobCopies = fields.get("copies")
-            lastjob.JobOptions = (fields.get("options") or "").decode("UTF-8").encode(self.tool.getCharset()) 
+            lastjob.JobOptions = unicode((fields.get("options") or ""), "UTF-8").encode(self.tool.getCharset()) 
             lastjob.JobDate = fields.get("jobdate")
             lastjob.JobHostName = fields.get("hostname")
@@ -323,5 +326,5 @@
                     printer.PricePerJob = record.get("priceperjob") or 0.0
                     printer.PricePerPage = record.get("priceperpage") or 0.0
-                    printer.Description = (record.get("description") or "").decode("UTF-8").encode(self.tool.getCharset()) 
+                    printer.Description = unicode((record.get("description") or ""), "UTF-8").encode(self.tool.getCharset()) 
                     printer.Exists = 1
                     printers.append(printer)
@@ -411,5 +414,5 @@
         description = printer.Description
         if description is not None :
-            description = printer.Description.decode(self.tool.getCharset()).encode("UTF-8"), 
+            description = unicode(printer.Description, self.tool.getCharset()).encode("UTF-8"), 
         self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(description), self.doQuote(printer.ident)))
         
@@ -460,9 +463,9 @@
         """Adds a job in a printer's history."""
         if filename is not None :
-            filename = filename.decode(self.tool.getCharset()).encode("UTF-8")
+            filename = unicode(filename, self.tool.getCharset()).encode("UTF-8")
         if title is not None :
-            title = title.decode(self.tool.getCharset()).encode("UTF-8")
+            title = unicode(title, self.tool.getCharset()).encode("UTF-8")
         if options is not None :
-            options = options.decode(self.tool.getCharset()).encode("UTF-8")
+            options = unicode(options, self.tool.getCharset()).encode("UTF-8")
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             if jobsize is not None :
@@ -524,8 +527,8 @@
                 job.JobPrice = fields.get("jobprice")
                 job.JobAction = fields.get("action")
-                job.JobFileName = (fields.get("filename") or "").decode("UTF-8").encode(self.tool.getCharset()) 
-                job.JobTitle = (fields.get("title") or "").decode("UTF-8").encode(self.tool.getCharset()) 
+                job.JobFileName = unicode((fields.get("filename") or ""), "UTF-8").encode(self.tool.getCharset()) 
+                job.JobTitle = unicode((fields.get("title") or ""), "UTF-8").encode(self.tool.getCharset()) 
                 job.JobCopies = fields.get("copies")
-                job.JobOptions = (fields.get("options") or "").decode("UTF-8").encode(self.tool.getCharset()) 
+                job.JobOptions = unicode((fields.get("options") or ""), "UTF-8").encode(self.tool.getCharset()) 
                 job.JobDate = fields.get("jobdate")
                 job.JobHostName = fields.get("hostname")
Index: pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- pykota/trunk/pykota/storages/ldapstorage.py (revision 1768)
+++ pykota/trunk/pykota/storages/ldapstorage.py (revision 1777)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.82  2004/10/05 09:59:20  jalet
+# Restore compatibility with Python 2.1
+#
 # Revision 1.81  2004/10/04 11:27:57  jalet
 # Finished LDAP support for dumpykota.
@@ -589,5 +592,5 @@
             printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0)
             printer.uniqueMember = fields.get("uniqueMember", [])
-            printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
+            printer.Description = unicode(fields.get("description", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
             printer.Exists = 1
         return printer    
@@ -690,8 +693,8 @@
                     lastjob.JobPrice = None
                 lastjob.JobAction = fields.get("pykotaAction", [""])[0]
-                lastjob.JobFileName = fields.get("pykotaFileName", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
-                lastjob.JobTitle = fields.get("pykotaTitle", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
+                lastjob.JobFileName = unicode(fields.get("pykotaFileName", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
+                lastjob.JobTitle = unicode(fields.get("pykotaTitle", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
                 lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0])
-                lastjob.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
+                lastjob.JobOptions = unicode(fields.get("pykotaOptions", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
                 lastjob.JobHostName = fields.get("pykotaHostName", [""])[0]
                 lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
@@ -766,5 +769,5 @@
                 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0)
                 printer.uniqueMember = fields.get("uniqueMember", [])
-                printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
+                printer.Description = unicode(fields.get("description", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
                 printer.Exists = 1
                 printers.append(printer)
@@ -978,5 +981,5 @@
         """Write the printer's description back into the storage."""
         fields = {
-                   "description" : str(printer.Description).decode(self.tool.getCharset()).encode("UTF-8"), 
+                   "description" : unicode(str(printer.Description), self.tool.getCharset()).encode("UTF-8"), 
                  }
         self.doModify(printer.ident, fields)
@@ -1077,8 +1080,8 @@
                    "pykotaPrinterPageCounter" : str(pagecounter),
                    "pykotaAction" : action,
-                   "pykotaFileName" : ((filename is None) and "None") or filename.decode(self.tool.getCharset()).encode("UTF-8"), 
-                   "pykotaTitle" : ((title is None) and "None") or title.decode(self.tool.getCharset()).encode("UTF-8"), 
+                   "pykotaFileName" : ((filename is None) and "None") or unicode(filename, self.tool.getCharset()).encode("UTF-8"), 
+                   "pykotaTitle" : ((title is None) and "None") or unicode(title, self.tool.getCharset()).encode("UTF-8"), 
                    "pykotaCopies" : str(copies), 
-                   "pykotaOptions" : ((options is None) and "None") or options.decode(self.tool.getCharset()).encode("UTF-8"), 
+                   "pykotaOptions" : ((options is None) and "None") or unicode(options, self.tool.getCharset()).encode("UTF-8"), 
                    "pykotaHostName" : str(clienthost), 
                    "pykotaJobSizeBytes" : str(jobsizebytes),
@@ -1179,8 +1182,8 @@
                     job.JobPrice = None
                 job.JobAction = fields.get("pykotaAction", [""])[0]
-                job.JobFileName = fields.get("pykotaFileName", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
-                job.JobTitle = fields.get("pykotaTitle", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
+                job.JobFileName = unicode(fields.get("pykotaFileName", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
+                job.JobTitle = unicode(fields.get("pykotaTitle", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
                 job.JobCopies = int(fields.get("pykotaCopies", [0])[0])
-                job.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
+                job.JobOptions = unicode(fields.get("pykotaOptions", [""])[0], "UTF-8").encode(self.tool.getCharset()) 
                 job.JobHostName = fields.get("pykotaHostName", [""])[0]
                 job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
Index: pykota/trunk/bin/dumpykota
===================================================================
--- pykota/trunk/bin/dumpykota (revision 1771)
+++ pykota/trunk/bin/dumpykota (revision 1777)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.8  2004/10/05 09:59:19  jalet
+# Restore compatibility with Python 2.1
+#
 # Revision 1.7  2004/10/04 21:25:29  jalet
 # dumpykota can now output datas in the XML format
@@ -218,5 +221,5 @@
             for i in range(len(entry)) :
                 value = entry[i]
-                strvalue = str(value).decode(self.getCharset()).encode("UTF-8")
+                strvalue = unicode(str(value), self.getCharset()).encode("UTF-8")
                 x.attribute(strvalue, type=type(value).__name__, name=headers[i])
             x._pop()    
