Changeset 1790 for pykota/trunk/pykota/storages/sql.py
- Timestamp:
- 10/07/04 23:14:28 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/sql.py
r1787 r1790 22 22 # 23 23 # $Log$ 24 # Revision 1.56 2004/10/07 21:14:28 jalet 25 # Hopefully final fix for data encoding to and from the database 26 # 24 27 # Revision 1.55 2004/10/07 09:37:53 jalet 25 28 # Fixes recently introduced bug wrt users groups (was it three days ago ?) … … 114 117 field = fields[j] 115 118 if type(field) == StringType : 116 try : 117 fields[j] = unicode(field, "UTF-8").encode(self.tool.getCharset()) 118 except UnicodeError : # takes care of old jobs in history not stored as UTF-8 119 pass 119 fields[j] = self.databaseToUserCharset(field) 120 120 entries[i] = tuple(fields) 121 121 return entries … … 224 224 printer.PricePerJob = fields.get("priceperjob") or 0.0 225 225 printer.PricePerPage = fields.get("priceperpage") or 0.0 226 printer.Description = unicode((fields.get("description") or ""), "UTF-8").encode(self.tool.getCharset())226 printer.Description = self.databaseToUserCharset(fields.get("description") or "") 227 227 printer.Exists = 1 228 228 return printer … … 276 276 lastjob.JobPrice = fields.get("jobprice") 277 277 lastjob.JobAction = fields.get("action") 278 lastjob.JobFileName = unicode((fields.get("filename") or ""), "UTF-8").encode(self.tool.getCharset())279 lastjob.JobTitle = unicode((fields.get("title") or ""), "UTF-8").encode(self.tool.getCharset())278 lastjob.JobFileName = self.databaseToUserCharset(fields.get("filename") or "") 279 lastjob.JobTitle = self.databaseToUserCharset(fields.get("title") or "") 280 280 lastjob.JobCopies = fields.get("copies") 281 lastjob.JobOptions = unicode((fields.get("options") or ""), "UTF-8").encode(self.tool.getCharset())281 lastjob.JobOptions = self.databaseToUserCharset(fields.get("options") or "") 282 282 lastjob.JobDate = fields.get("jobdate") 283 283 lastjob.JobHostName = fields.get("hostname") … … 338 338 printer.PricePerJob = record.get("priceperjob") or 0.0 339 339 printer.PricePerPage = record.get("priceperpage") or 0.0 340 printer.Description = unicode((record.get("description") or ""), "UTF-8").encode(self.tool.getCharset())340 printer.Description = self.databaseToUserCharset(record.get("description") or "") 341 341 printer.Exists = 1 342 342 printers.append(printer) … … 424 424 def writePrinterDescription(self, printer) : 425 425 """Write the printer's description back into the storage.""" 426 description = printer.Description 427 if description is not None : 428 description = unicode(printer.Description, self.tool.getCharset()).encode("UTF-8"), 426 description = self.userCharsetToDatabase(printer.Description) 429 427 self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(description), self.doQuote(printer.ident))) 430 428 … … 474 472 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) : 475 473 """Adds a job in a printer's history.""" 476 if filename is not None : 477 filename = unicode(filename, self.tool.getCharset()).encode("UTF-8") 478 if title is not None : 479 title = unicode(title, self.tool.getCharset()).encode("UTF-8") 480 if options is not None : 481 options = unicode(options, self.tool.getCharset()).encode("UTF-8") 474 filename = self.userCharsetToDatabase(filename) 475 title = self.userCharsetToDatabase(title) 476 options = self.userCharsetToDatabase(options) 482 477 if (not self.disablehistory) or (not printer.LastJob.Exists) : 483 478 if jobsize is not None : … … 539 534 job.JobPrice = fields.get("jobprice") 540 535 job.JobAction = fields.get("action") 541 job.JobFileName = unicode((fields.get("filename") or ""), "UTF-8").encode(self.tool.getCharset())542 job.JobTitle = unicode((fields.get("title") or ""), "UTF-8").encode(self.tool.getCharset())536 job.JobFileName = self.databaseToUserCharset(fields.get("filename") or "") 537 job.JobTitle = self.databaseToUserCharset(fields.get("title") or "") 543 538 job.JobCopies = fields.get("copies") 544 job.JobOptions = unicode((fields.get("options") or ""), "UTF-8").encode(self.tool.getCharset())539 job.JobOptions = self.databaseToUserCharset(fields.get("options") or "") 545 540 job.JobDate = fields.get("jobdate") 546 541 job.JobHostName = fields.get("hostname")