Changeset 1777

Show
Ignore:
Timestamp:
10/05/04 11:59:20 (20 years ago)
Author:
jalet
Message:

Restore compatibility with Python 2.1

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/dumpykota

    r1771 r1777  
    2424# 
    2525# $Log$ 
     26# Revision 1.8  2004/10/05 09:59:19  jalet 
     27# Restore compatibility with Python 2.1 
     28# 
    2629# Revision 1.7  2004/10/04 21:25:29  jalet 
    2730# dumpykota can now output datas in the XML format 
     
    218221            for i in range(len(entry)) : 
    219222                value = entry[i] 
    220                 strvalue = str(value).decode(self.getCharset()).encode("UTF-8") 
     223                strvalue = unicode(str(value), self.getCharset()).encode("UTF-8") 
    221224                x.attribute(strvalue, type=type(value).__name__, name=headers[i]) 
    222225            x._pop()     
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1768 r1777  
    2222# 
    2323# $Log$ 
     24# Revision 1.82  2004/10/05 09:59:20  jalet 
     25# Restore compatibility with Python 2.1 
     26# 
    2427# Revision 1.81  2004/10/04 11:27:57  jalet 
    2528# Finished LDAP support for dumpykota. 
     
    589592            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    590593            printer.uniqueMember = fields.get("uniqueMember", []) 
    591             printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     594            printer.Description = unicode(fields.get("description", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    592595            printer.Exists = 1 
    593596        return printer     
     
    690693                    lastjob.JobPrice = None 
    691694                lastjob.JobAction = fields.get("pykotaAction", [""])[0] 
    692                 lastjob.JobFileName = fields.get("pykotaFileName", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    693                 lastjob.JobTitle = fields.get("pykotaTitle", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     695                lastjob.JobFileName = unicode(fields.get("pykotaFileName", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     696                lastjob.JobTitle = unicode(fields.get("pykotaTitle", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    694697                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    695                 lastjob.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     698                lastjob.JobOptions = unicode(fields.get("pykotaOptions", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    696699                lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 
    697700                lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
     
    766769                printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    767770                printer.uniqueMember = fields.get("uniqueMember", []) 
    768                 printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     771                printer.Description = unicode(fields.get("description", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    769772                printer.Exists = 1 
    770773                printers.append(printer) 
     
    978981        """Write the printer's description back into the storage.""" 
    979982        fields = { 
    980                    "description" : str(printer.Description).decode(self.tool.getCharset()).encode("UTF-8"),  
     983                   "description" : unicode(str(printer.Description), self.tool.getCharset()).encode("UTF-8"),  
    981984                 } 
    982985        self.doModify(printer.ident, fields) 
     
    10771080                   "pykotaPrinterPageCounter" : str(pagecounter), 
    10781081                   "pykotaAction" : action, 
    1079                    "pykotaFileName" : ((filename is None) and "None") or filename.decode(self.tool.getCharset()).encode("UTF-8"),  
    1080                    "pykotaTitle" : ((title is None) and "None") or title.decode(self.tool.getCharset()).encode("UTF-8"),  
     1082                   "pykotaFileName" : ((filename is None) and "None") or unicode(filename, self.tool.getCharset()).encode("UTF-8"),  
     1083                   "pykotaTitle" : ((title is None) and "None") or unicode(title, self.tool.getCharset()).encode("UTF-8"),  
    10811084                   "pykotaCopies" : str(copies),  
    1082                    "pykotaOptions" : ((options is None) and "None") or options.decode(self.tool.getCharset()).encode("UTF-8"),  
     1085                   "pykotaOptions" : ((options is None) and "None") or unicode(options, self.tool.getCharset()).encode("UTF-8"),  
    10831086                   "pykotaHostName" : str(clienthost),  
    10841087                   "pykotaJobSizeBytes" : str(jobsizebytes), 
     
    11791182                    job.JobPrice = None 
    11801183                job.JobAction = fields.get("pykotaAction", [""])[0] 
    1181                 job.JobFileName = fields.get("pykotaFileName", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    1182                 job.JobTitle = fields.get("pykotaTitle", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     1184                job.JobFileName = unicode(fields.get("pykotaFileName", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     1185                job.JobTitle = unicode(fields.get("pykotaTitle", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    11831186                job.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    1184                 job.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     1187                job.JobOptions = unicode(fields.get("pykotaOptions", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    11851188                job.JobHostName = fields.get("pykotaHostName", [""])[0] 
    11861189                job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
  • pykota/trunk/pykota/storages/sql.py

    r1773 r1777  
    2222# 
    2323# $Log$ 
     24# Revision 1.53  2004/10/05 09:59:20  jalet 
     25# Restore compatibility with Python 2.1 
     26# 
    2427# Revision 1.52  2004/10/04 22:23:54  jalet 
    2528# Charset conversions for dumps from the PostgreSQL backend 
     
    106109                    if type(field) == StringType : 
    107110                        try : 
    108                             fields[j] = field.decode("UTF-8").encode(self.tool.getCharset())  
     111                            fields[j] = unicode(field, "UTF-8").encode(self.tool.getCharset())  
    109112                        except UnicodeEncodeError : # takes care of old jobs in history not stored as UTF-8     
    110113                            pass 
     
    212215            printer.PricePerJob = fields.get("priceperjob") or 0.0 
    213216            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())  
    215218            printer.Exists = 1 
    216219        return printer     
     
    261264            lastjob.JobPrice = fields.get("jobprice") 
    262265            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())  
    265268            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())  
    267270            lastjob.JobDate = fields.get("jobdate") 
    268271            lastjob.JobHostName = fields.get("hostname") 
     
    323326                    printer.PricePerJob = record.get("priceperjob") or 0.0 
    324327                    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())  
    326329                    printer.Exists = 1 
    327330                    printers.append(printer) 
     
    411414        description = printer.Description 
    412415        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"),  
    414417        self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(description), self.doQuote(printer.ident))) 
    415418         
     
    460463        """Adds a job in a printer's history.""" 
    461464        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") 
    463466        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") 
    465468        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") 
    467470        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
    468471            if jobsize is not None : 
     
    524527                job.JobPrice = fields.get("jobprice") 
    525528                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())  
    528531                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())  
    530533                job.JobDate = fields.get("jobdate") 
    531534                job.JobHostName = fields.get("hostname")