Changeset 3541

Show
Ignore:
Timestamp:
04/22/10 11:13:59 (14 years ago)
Author:
jerome
Message:

I've finally killed this one (exactly the sort of thing I've said for
several years wrt such charset encoding problems) ! The problem was not
in the encoding of the title attribute of the job, which was perfectly
correct, but in the jobid attribute, which was still in unicode instead
of in UTF-8. This particular situation made the query string be
transformed to unicode, and an utf-8 encoded title couldn't be inserted
into it, making PyKota fail miserably.
Fixes #56. References #60, #61.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/sql.py

    r3531 r3541  
    7575        """Sets the attributes of a job from a database record.""" 
    7676        job.ident = record.get("id") 
    77         job.JobId = record.get("jobid") 
     77        job.JobId = databaseToUnicode(record.get("jobid")) 
    7878        job.PrinterPageCounter = record.get("pagecounter") 
    7979        job.JobSize = record.get("jobsize") 
     
    741741                                  % (self.doQuote(user.ident), 
    742742                                     self.doQuote(printer.ident), 
    743                                      self.doQuote(jobid), 
     743                                     self.doQuote(unicodeToDatabase(jobid)), 
    744744                                     self.doQuote(pagecounter), 
    745745                                     self.doQuote(action), 
     
    761761                                  % (self.doQuote(user.ident), 
    762762                                     self.doQuote(printer.ident), 
    763                                      self.doQuote(jobid), 
     763                                     self.doQuote(unicodeToDatabase(jobid)), 
    764764                                     self.doQuote(pagecounter), 
    765765                                     self.doQuote(action), 
     
    779779            self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, hostname=%s, jobsizebytes=%s, md5sum=%s, pages=%s, billingcode=%s, precomputedjobsize=%s, precomputedjobprice=%s, jobdate=now() WHERE id=%s" \ 
    780780                              % (self.doQuote(user.ident), 
    781                                  self.doQuote(jobid), 
     781                                 self.doQuote(unicodeToDatabase(jobid)), 
    782782                                 self.doQuote(pagecounter), 
    783783                                 self.doQuote(action), 
     
    855855            where.append("billingcode=%s" % self.doQuote(unicodeToDatabase(billingcode))) 
    856856        if jobid is not None : 
    857             where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so unicodeToDatabase(jobid) but do all of them as well. 
     857            where.append("jobid=%s" % self.doQuote(unicodeToDatabase(jobid))) 
    858858        if start is not None : 
    859859            where.append("jobdate>=%s" % self.doQuote(start))