Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 3275)
+++ pykota/trunk/pykota/storages/sql.py (revision 3291)
@@ -36,5 +36,5 @@
         user.LifeTimePaid = record.get("lifetimepaid")
         user.Email = record.get("email")
-        user.Description = self.databaseToUserCharset(record.get("description"))
+        user.Description = self.databaseToUnicode(record.get("description"))
         user.OverCharge = record.get("overcharge", 1.0)
         user.Exists = True
@@ -48,5 +48,5 @@
         group.AccountBalance = record.get("balance")
         group.LifeTimePaid = record.get("lifetimepaid")
-        group.Description = self.databaseToUserCharset(record.get("description"))
+        group.Description = self.databaseToUnicode(record.get("description"))
         group.Exists = True
         return group
@@ -64,5 +64,5 @@
         else :
             printer.PassThrough = False
-        printer.Description = self.databaseToUserCharset(record.get("description") or "") # TODO : is 'or ""' still needed ?
+        printer.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ?
         printer.Exists = True
         return printer
@@ -76,8 +76,8 @@
         job.JobPrice = record.get("jobprice")
         job.JobAction = record.get("action")
-        job.JobFileName = self.databaseToUserCharset(record.get("filename") or "") 
-        job.JobTitle = self.databaseToUserCharset(record.get("title") or "") 
+        job.JobFileName = self.databaseToUnicode(record.get("filename") or "") 
+        job.JobTitle = self.databaseToUnicode(record.get("title") or "") 
         job.JobCopies = record.get("copies")
-        job.JobOptions = self.databaseToUserCharset(record.get("options") or "") 
+        job.JobOptions = self.databaseToUnicode(record.get("options") or "") 
         job.JobDate = record.get("jobdate")
         job.JobHostName = record.get("hostname")
@@ -85,9 +85,9 @@
         job.JobMD5Sum = record.get("md5sum")
         job.JobPages = record.get("pages")
-        job.JobBillingCode = self.databaseToUserCharset(record.get("billingcode") or "")
+        job.JobBillingCode = self.databaseToUnicode(record.get("billingcode") or "")
         job.PrecomputedJobSize = record.get("precomputedjobsize")
         job.PrecomputedJobPrice = record.get("precomputedjobprice")
-        job.UserName = self.databaseToUserCharset(record.get("username"))
-        job.PrinterName = self.databaseToUserCharset(record.get("printername"))
+        job.UserName = self.databaseToUnicode(record.get("username"))
+        job.PrinterName = self.databaseToUnicode(record.get("printername"))
         if job.JobTitle == job.JobFileName == job.JobOptions == "hidden" :
             (job.JobTitle, job.JobFileName, job.JobOptions) = (_("Hidden because of privacy concerns"),) * 3
@@ -138,5 +138,5 @@
         code = StorageBillingCode(self, billingcode)
         code.ident = record.get("id")
-        code.Description = self.databaseToUserCharset(record.get("description") or "") # TODO : is 'or ""' still needed ?
+        code.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ?
         code.Balance = record.get("balance") or 0.0
         code.PageCounter = record.get("pagecounter") or 0
@@ -149,5 +149,5 @@
             expressions = []
             for (k, v) in only.items() :
-                expressions.append("%s=%s" % (k, self.doQuote(self.userCharsetToDatabase(v))))
+                expressions.append("%s=%s" % (k, self.doQuote(self.unicodeToDatabase(v))))
             return " AND ".join(expressions)     
         return ""        
@@ -299,5 +299,5 @@
                 self.tool.printInfo("Object %s has no %s attribute !" % (repr(record), attribute), "error")
             else :
-                attrval = self.databaseToUserCharset(attrval)
+                attrval = self.databaseToUnicode(attrval)
                 if patterns :
                     if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) :
@@ -351,5 +351,5 @@
         """Extracts user information given its name."""
         result = self.doSearch("SELECT * FROM users WHERE username=%s"\
-                      % self.doQuote(self.userCharsetToDatabase(username)))
+                      % self.doQuote(self.unicodeToDatabase(username)))
         if result :
             return self.storageUserFromRecord(username, result[0])
@@ -360,5 +360,5 @@
         """Extracts group information given its name."""
         result = self.doSearch("SELECT groups.*,COALESCE(SUM(balance), 0.0) AS balance, COALESCE(SUM(lifetimepaid), 0.0) AS lifetimepaid FROM groups LEFT OUTER JOIN users ON users.id IN (SELECT userid FROM groupsmembers WHERE groupid=groups.id) WHERE groupname=%s GROUP BY groups.id,groups.groupname,groups.limitby,groups.description" \
-                      % self.doQuote(self.userCharsetToDatabase(groupname)))
+                      % self.doQuote(self.unicodeToDatabase(groupname)))
         if result :
             return self.storageGroupFromRecord(groupname, result[0])
@@ -369,5 +369,5 @@
         """Extracts printer information given its name."""
         result = self.doSearch("SELECT * FROM printers WHERE printername=%s" \
-                      % self.doQuote(self.userCharsetToDatabase(printername)))
+                      % self.doQuote(self.unicodeToDatabase(printername)))
         if result :
             return self.storagePrinterFromRecord(printername, result[0])
@@ -378,5 +378,5 @@
         """Extracts a billing code information given its name."""
         result = self.doSearch("SELECT * FROM billingcodes WHERE billingcode=%s" \
-                      % self.doQuote(self.userCharsetToDatabase(label)))
+                      % self.doQuote(self.unicodeToDatabase(label)))
         if result :
             return self.storageBillingCodeFromRecord(label, result[0])
@@ -416,5 +416,5 @@
         if result :
             for record in result :
-                user = self.storageUserFromRecord(self.databaseToUserCharset(record.get("username")), \
+                user = self.storageUserFromRecord(self.databaseToUnicode(record.get("username")), \
                                                   record)
                 groupmembers.append(user)
@@ -428,5 +428,5 @@
         if result :
             for record in result :
-                groups.append(self.getGroup(self.databaseToUserCharset(record.get("groupname"))))
+                groups.append(self.getGroup(self.databaseToUnicode(record.get("groupname"))))
         return groups        
         
@@ -438,5 +438,5 @@
             for record in result :
                 if record["groupid"] != printer.ident : # in case of integrity violation
-                    parentprinter = self.getPrinter(self.databaseToUserCharset(record.get("printername")))
+                    parentprinter = self.getPrinter(self.databaseToUnicode(record.get("printername")))
                     if parentprinter.Exists :
                         pgroups.append(parentprinter)
@@ -460,5 +460,5 @@
                     patdict[p] = None
             for record in result :
-                pname = self.databaseToUserCharset(record["printername"])
+                pname = self.databaseToUnicode(record["printername"])
                 if patdict.has_key(pname) or self.tool.matchString(pname, patterns) :
                     printer = self.storagePrinterFromRecord(pname, record)
@@ -484,5 +484,5 @@
                     patdict[p] = None
             for record in result :
-                uname = self.databaseToUserCharset(record["username"])
+                uname = self.databaseToUnicode(record["username"])
                 if patdict.has_key(uname) or self.tool.matchString(uname, patterns) :
                     user = self.storageUserFromRecord(uname, record)
@@ -508,5 +508,5 @@
                     patdict[p] = None
             for record in result :
-                gname = self.databaseToUserCharset(record["groupname"])
+                gname = self.databaseToUnicode(record["groupname"])
                 if patdict.has_key(gname) or self.tool.matchString(gname, patterns) :
                     group = self.storageGroupFromRecord(gname, record)
@@ -529,5 +529,5 @@
                     patdict[p] = None
             for record in result :
-                codename = self.databaseToUserCharset(record["billingcode"])
+                codename = self.databaseToUnicode(record["billingcode"])
                 if patdict.has_key(codename) or self.tool.matchString(codename, patterns) :
                     code = self.storageBillingCodeFromRecord(codename, record)
@@ -542,5 +542,5 @@
         if result :
             for record in result :
-                uname = self.databaseToUserCharset(record.get("username"))
+                uname = self.databaseToUnicode(record.get("username"))
                 if self.tool.matchString(uname, names) :
                     user = self.storageUserFromRecord(uname, record)
@@ -557,5 +557,5 @@
         if result :
             for record in result :
-                gname = self.databaseToUserCharset(record.get("groupname"))
+                gname = self.databaseToUnicode(record.get("groupname"))
                 if self.tool.matchString(gname, names) :
                     group = self.getGroup(gname)
@@ -570,8 +570,8 @@
             return oldentry
         self.doModify("INSERT INTO printers (printername, passthrough, maxjobsize, description, priceperpage, priceperjob) VALUES (%s, %s, %s, %s, %s, %s)" \
-                          % (self.doQuote(self.userCharsetToDatabase(printer.Name)), \
+                          % (self.doQuote(self.unicodeToDatabase(printer.Name)), \
                              self.doQuote((printer.PassThrough and "t") or "f"), \
                              self.doQuote(printer.MaxJobSize or 0), \
-                             self.doQuote(self.userCharsetToDatabase(printer.Description)), \
+                             self.doQuote(self.unicodeToDatabase(printer.Description)), \
                              self.doQuote(printer.PricePerPage or 0.0), \
                              self.doQuote(printer.PricePerJob or 0.0)))
@@ -585,8 +585,8 @@
             return oldentry
         self.doModify("INSERT INTO billingcodes (billingcode, balance, pagecounter, description) VALUES (%s, %s, %s, %s)" \
-                           % (self.doQuote(self.userCharsetToDatabase(bcode.BillingCode)), 
+                           % (self.doQuote(self.unicodeToDatabase(bcode.BillingCode)), 
                               self.doQuote(bcode.Balance or 0.0), \
                               self.doQuote(bcode.PageCounter or 0), \
-                              self.doQuote(self.userCharsetToDatabase(bcode.Description))))
+                              self.doQuote(self.unicodeToDatabase(bcode.Description))))
         bcode.isDirty = False
         return None # the entry created doesn't need further modification
@@ -598,5 +598,5 @@
             return oldentry
         self.doModify("INSERT INTO users (username, limitby, balance, lifetimepaid, email, overcharge, description) VALUES (%s, %s, %s, %s, %s, %s, %s)" % \
-                                     (self.doQuote(self.userCharsetToDatabase(user.Name)), \
+                                     (self.doQuote(self.unicodeToDatabase(user.Name)), \
                                       self.doQuote(user.LimitBy or 'quota'), \
                                       self.doQuote(user.AccountBalance or 0.0), \
@@ -604,5 +604,5 @@
                                       self.doQuote(user.Email), \
                                       self.doQuote(user.OverCharge), \
-                                      self.doQuote(self.userCharsetToDatabase(user.Description))))
+                                      self.doQuote(self.unicodeToDatabase(user.Description))))
         if user.PaymentsBacklog :
             for (value, comment) in user.PaymentsBacklog :
@@ -618,7 +618,7 @@
             return oldentry
         self.doModify("INSERT INTO groups (groupname, limitby, description) VALUES (%s, %s, %s)" % \
-                              (self.doQuote(self.userCharsetToDatabase(group.Name)), \
+                              (self.doQuote(self.unicodeToDatabase(group.Name)), \
                                self.doQuote(group.LimitBy or "quota"), \
-                               self.doQuote(self.userCharsetToDatabase(group.Description))))
+                               self.doQuote(self.unicodeToDatabase(group.Description))))
         group.isDirty = False
         return None # the entry created doesn't need further modification
@@ -677,5 +677,5 @@
                               % (self.doQuote((printer.PassThrough and "t") or "f"), \
                                  self.doQuote(printer.MaxJobSize or 0), \
-                                 self.doQuote(self.userCharsetToDatabase(printer.Description)), \
+                                 self.doQuote(self.unicodeToDatabase(printer.Description)), \
                                  self.doQuote(printer.PricePerPage or 0.0), \
                                  self.doQuote(printer.PricePerJob or 0.0), \
@@ -690,5 +690,5 @@
                                   self.doQuote(user.Email), \
                                   self.doQuote(user.OverCharge), \
-                                  self.doQuote(self.userCharsetToDatabase(user.Description)), \
+                                  self.doQuote(self.unicodeToDatabase(user.Description)), \
                                   self.doQuote(user.ident)))
                                   
@@ -697,5 +697,5 @@
         self.doModify("UPDATE groups SET limitby=%s, description=%s WHERE id=%s" \
                                % (self.doQuote(group.LimitBy or 'quota'), \
-                                  self.doQuote(self.userCharsetToDatabase(group.Description)), \
+                                  self.doQuote(self.unicodeToDatabase(group.Description)), \
                                   self.doQuote(group.ident)))
         
@@ -717,5 +717,5 @@
                             % (self.doQuote(bcode.Balance or 0.0), \
                                self.doQuote(bcode.PageCounter or 0), \
-                               self.doQuote(self.userCharsetToDatabase(bcode.Description)), \
+                               self.doQuote(self.unicodeToDatabase(bcode.Description)), \
                                self.doQuote(bcode.ident)))
        
@@ -735,7 +735,7 @@
         """Adds a new payment to the payments history."""
         if user.ident is not None :
-            self.doModify("INSERT INTO payments (userid, amount, description) VALUES (%s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(amount), self.doQuote(self.userCharsetToDatabase(comment))))
+            self.doModify("INSERT INTO payments (userid, amount, description) VALUES (%s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(amount), self.doQuote(self.unicodeToDatabase(comment))))
         else :    
-            self.doModify("INSERT INTO payments (userid, amount, description) VALUES ((SELECT id FROM users WHERE username=%s), %s, %s)" % (self.doQuote(self.userCharsetToDatabase(user.Name)), self.doQuote(amount), self.doQuote(self.userCharsetToDatabase(comment))))
+            self.doModify("INSERT INTO payments (userid, amount, description) VALUES ((SELECT id FROM users WHERE username=%s), %s, %s)" % (self.doQuote(self.unicodeToDatabase(user.Name)), self.doQuote(amount), self.doQuote(self.unicodeToDatabase(comment))))
         
     def writeLastJobSize(self, lastjob, jobsize, jobprice) :        
@@ -748,8 +748,8 @@
             # For legal reasons, we want to hide the title, filename and options
             title = filename = options = "hidden"
-        filename = self.userCharsetToDatabase(filename)
-        title = self.userCharsetToDatabase(title)
-        options = self.userCharsetToDatabase(options)
-        jobbilling = self.userCharsetToDatabase(jobbilling)
+        filename = self.unicodeToDatabase(filename)
+        title = self.unicodeToDatabase(title)
+        options = self.unicodeToDatabase(options)
+        jobbilling = self.unicodeToDatabase(jobbilling)
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             if jobsize is not None :
@@ -814,7 +814,7 @@
             where.append("hostname=%s" % self.doQuote(hostname))
         if billingcode is not None :    
-            where.append("billingcode=%s" % self.doQuote(self.userCharsetToDatabase(billingcode)))
+            where.append("billingcode=%s" % self.doQuote(self.unicodeToDatabase(billingcode)))
         if jobid is not None :    
-            where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so self.userCharsetToDatabase(jobid) but do all of them as well.
+            where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so self.unicodeToDatabase(jobid) but do all of them as well.
         if start is not None :    
             where.append("jobdate>=%s" % self.doQuote(start))
