Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 1719)
+++ pykota/trunk/pykota/storages/sql.py (revision 1761)
@@ -22,4 +22,8 @@
 #
 # $Log$
+# Revision 1.48  2004/10/02 05:48:56  jalet
+# Should now correctly deal with charsets both when storing into databases and when
+# retrieving datas. Works with both PostgreSQL and LDAP.
+#
 # Revision 1.47  2004/09/15 07:26:20  jalet
 # Data dumps are now ordered by entry creation date if applicable.
@@ -187,5 +191,5 @@
             printer.PricePerJob = fields.get("priceperjob") or 0.0
             printer.PricePerPage = fields.get("priceperpage") or 0.0
-            printer.Description = fields.get("description") or ""
+            printer.Description = (fields.get("description") or "").decode("UTF-8").encode(self.tool.getCharset()) 
             printer.Exists = 1
         return printer    
@@ -239,8 +243,8 @@
             lastjob.JobPrice = fields.get("jobprice")
             lastjob.JobAction = fields.get("action")
-            lastjob.JobFileName = fields.get("filename")
-            lastjob.JobTitle = fields.get("title")
+            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.JobCopies = fields.get("copies")
-            lastjob.JobOptions = fields.get("options")
+            lastjob.JobOptions = (fields.get("options") or "").decode("UTF-8").encode(self.tool.getCharset()) 
             lastjob.JobDate = fields.get("jobdate")
             lastjob.JobHostName = fields.get("hostname")
@@ -301,5 +305,5 @@
                     printer.PricePerJob = record.get("priceperjob") or 0.0
                     printer.PricePerPage = record.get("priceperpage") or 0.0
-                    printer.Description = record.get("description") or ""
+                    printer.Description = (record.get("description") or "").decode("UTF-8").encode(self.tool.getCharset()) 
                     printer.Exists = 1
                     printers.append(printer)
@@ -387,5 +391,8 @@
     def writePrinterDescription(self, printer) :    
         """Write the printer's description back into the storage."""
-        self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(printer.Description), self.doQuote(printer.ident)))
+        description = printer.Description
+        if description is not None :
+            description = printer.Description.decode(self.tool.getCharset()).encode("UTF-8"), 
+        self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(description), self.doQuote(printer.ident)))
         
     def writeUserLimitBy(self, user, limitby) :    
@@ -432,6 +439,12 @@
         self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident)))
         
-    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) :    
+    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) :
         """Adds a job in a printer's history."""
+        if filename is not None :
+            filename = filename.decode(self.tool.getCharset()).encode("UTF-8")
+        if title is not None :
+            title = title.decode(self.tool.getCharset()).encode("UTF-8")
+        if options is not None :
+            options = options.decode(self.tool.getCharset()).encode("UTF-8")
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             if jobsize is not None :
@@ -493,8 +506,8 @@
                 job.JobPrice = fields.get("jobprice")
                 job.JobAction = fields.get("action")
-                job.JobFileName = fields.get("filename")
-                job.JobTitle = fields.get("title")
+                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.JobCopies = fields.get("copies")
-                job.JobOptions = fields.get("options")
+                job.JobOptions = (fields.get("options") or "").decode("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 1754)
+++ pykota/trunk/pykota/storages/ldapstorage.py (revision 1761)
@@ -22,4 +22,8 @@
 #
 # $Log$
+# Revision 1.78  2004/10/02 05:48:56  jalet
+# Should now correctly deal with charsets both when storing into databases and when
+# retrieving datas. Works with both PostgreSQL and LDAP.
+#
 # Revision 1.77  2004/09/28 14:29:00  jalet
 # dumpykota for LDAP backend is almost there.
@@ -576,5 +580,5 @@
             printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0)
             printer.uniqueMember = fields.get("uniqueMember", [])
-            printer.Description = fields.get("description", [""])[0]
+            printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
             printer.Exists = 1
         return printer    
@@ -677,8 +681,8 @@
                     lastjob.JobPrice = None
                 lastjob.JobAction = fields.get("pykotaAction", [""])[0]
-                lastjob.JobFileName = fields.get("pykotaFileName", [""])[0]
-                lastjob.JobTitle = fields.get("pykotaTitle", [""])[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.JobCopies = int(fields.get("pykotaCopies", [0])[0])
-                lastjob.JobOptions = fields.get("pykotaOptions", [""])[0]
+                lastjob.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
                 lastjob.JobHostName = fields.get("pykotaHostName", [""])[0]
                 lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
@@ -753,5 +757,5 @@
                 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0)
                 printer.uniqueMember = fields.get("uniqueMember", [])
-                printer.Description = fields.get("description", [""])[0]
+                printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
                 printer.Exists = 1
                 printers.append(printer)
@@ -965,5 +969,5 @@
         """Write the printer's description back into the storage."""
         fields = {
-                   "description" : str(printer.Description),
+                   "description" : str(printer.Description).decode(self.tool.getCharset()).encode("UTF-8"), 
                  }
         self.doModify(printer.ident, fields)
@@ -1064,8 +1068,8 @@
                    "pykotaPrinterPageCounter" : str(pagecounter),
                    "pykotaAction" : action,
-                   "pykotaFileName" : ((filename is None) and "None") or filename.decode(os.environ.get("CHARSET", "ISO-8859-15")).encode("UTF-8"), 
-                   "pykotaTitle" : ((title is None) and "None") or title.decode(os.environ.get("CHARSET", "ISO-8859-15")).encode("UTF-8"), 
+                   "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"), 
                    "pykotaCopies" : str(copies), 
-                   "pykotaOptions" : ((options is None) and "None") or options.decode(os.environ.get("CHARSET", "ISO-8859-15")).encode("UTF-8"), 
+                   "pykotaOptions" : ((options is None) and "None") or options.decode(self.tool.getCharset()).encode("UTF-8"), 
                    "pykotaHostName" : str(clienthost), 
                    "pykotaJobSizeBytes" : str(jobsizebytes),
@@ -1166,8 +1170,8 @@
                     job.JobPrice = None
                 job.JobAction = fields.get("pykotaAction", [""])[0]
-                job.JobFileName = fields.get("pykotaFileName", [""])[0]
-                job.JobTitle = fields.get("pykotaTitle", [""])[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.JobCopies = int(fields.get("pykotaCopies", [0])[0])
-                job.JobOptions = fields.get("pykotaOptions", [""])[0]
+                job.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset()) 
                 job.JobHostName = fields.get("pykotaHostName", [""])[0]
                 job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
