Changeset 1777 for pykota/trunk/pykota/storages/sql.py
- Timestamp:
- 10/05/04 11:59:20 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/sql.py
r1773 r1777 22 22 # 23 23 # $Log$ 24 # Revision 1.53 2004/10/05 09:59:20 jalet 25 # Restore compatibility with Python 2.1 26 # 24 27 # Revision 1.52 2004/10/04 22:23:54 jalet 25 28 # Charset conversions for dumps from the PostgreSQL backend … … 106 109 if type(field) == StringType : 107 110 try : 108 fields[j] = field.decode("UTF-8").encode(self.tool.getCharset())111 fields[j] = unicode(field, "UTF-8").encode(self.tool.getCharset()) 109 112 except UnicodeEncodeError : # takes care of old jobs in history not stored as UTF-8 110 113 pass … … 212 215 printer.PricePerJob = fields.get("priceperjob") or 0.0 213 216 printer.PricePerPage = fields.get("priceperpage") or 0.0 214 printer.Description = (fields.get("description") or "").decode("UTF-8").encode(self.tool.getCharset())217 printer.Description = unicode((fields.get("description") or ""), "UTF-8").encode(self.tool.getCharset()) 215 218 printer.Exists = 1 216 219 return printer … … 261 264 lastjob.JobPrice = fields.get("jobprice") 262 265 lastjob.JobAction = fields.get("action") 263 lastjob.JobFileName = (fields.get("filename") or "").decode("UTF-8").encode(self.tool.getCharset())264 lastjob.JobTitle = (fields.get("title") or "").decode("UTF-8").encode(self.tool.getCharset())266 lastjob.JobFileName = unicode((fields.get("filename") or ""), "UTF-8").encode(self.tool.getCharset()) 267 lastjob.JobTitle = unicode((fields.get("title") or ""), "UTF-8").encode(self.tool.getCharset()) 265 268 lastjob.JobCopies = fields.get("copies") 266 lastjob.JobOptions = (fields.get("options") or "").decode("UTF-8").encode(self.tool.getCharset())269 lastjob.JobOptions = unicode((fields.get("options") or ""), "UTF-8").encode(self.tool.getCharset()) 267 270 lastjob.JobDate = fields.get("jobdate") 268 271 lastjob.JobHostName = fields.get("hostname") … … 323 326 printer.PricePerJob = record.get("priceperjob") or 0.0 324 327 printer.PricePerPage = record.get("priceperpage") or 0.0 325 printer.Description = (record.get("description") or "").decode("UTF-8").encode(self.tool.getCharset())328 printer.Description = unicode((record.get("description") or ""), "UTF-8").encode(self.tool.getCharset()) 326 329 printer.Exists = 1 327 330 printers.append(printer) … … 411 414 description = printer.Description 412 415 if description is not None : 413 description = printer.Description.decode(self.tool.getCharset()).encode("UTF-8"),416 description = unicode(printer.Description, self.tool.getCharset()).encode("UTF-8"), 414 417 self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(description), self.doQuote(printer.ident))) 415 418 … … 460 463 """Adds a job in a printer's history.""" 461 464 if filename is not None : 462 filename = filename.decode(self.tool.getCharset()).encode("UTF-8")465 filename = unicode(filename, self.tool.getCharset()).encode("UTF-8") 463 466 if title is not None : 464 title = title.decode(self.tool.getCharset()).encode("UTF-8")467 title = unicode(title, self.tool.getCharset()).encode("UTF-8") 465 468 if options is not None : 466 options = options.decode(self.tool.getCharset()).encode("UTF-8")469 options = unicode(options, self.tool.getCharset()).encode("UTF-8") 467 470 if (not self.disablehistory) or (not printer.LastJob.Exists) : 468 471 if jobsize is not None : … … 524 527 job.JobPrice = fields.get("jobprice") 525 528 job.JobAction = fields.get("action") 526 job.JobFileName = (fields.get("filename") or "").decode("UTF-8").encode(self.tool.getCharset())527 job.JobTitle = (fields.get("title") or "").decode("UTF-8").encode(self.tool.getCharset())529 job.JobFileName = unicode((fields.get("filename") or ""), "UTF-8").encode(self.tool.getCharset()) 530 job.JobTitle = unicode((fields.get("title") or ""), "UTF-8").encode(self.tool.getCharset()) 528 531 job.JobCopies = fields.get("copies") 529 job.JobOptions = (fields.get("options") or "").decode("UTF-8").encode(self.tool.getCharset())532 job.JobOptions = unicode((fields.get("options") or ""), "UTF-8").encode(self.tool.getCharset()) 530 533 job.JobDate = fields.get("jobdate") 531 534 job.JobHostName = fields.get("hostname")