Show
Ignore:
Timestamp:
04/30/03 15:36:40 (21 years ago)
Author:
jalet
Message:

Stupid accounting method was added.

Location:
pykota/trunk/pykota/storages
Files:
2 modified

Legend:

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

    r967 r976  
    2121# 
    2222# $Log$ 
     23# Revision 1.10  2003/04/30 13:36:40  jalet 
     24# Stupid accounting method was added. 
     25# 
    2326# Revision 1.9  2003/04/27 08:04:15  jalet 
    2427# LDAP storage backend's skeleton added. DOESN'T WORK. 
     
    111114    def doQuote(self, field) : 
    112115        """Quotes a field for use as a string in SQL queries.""" 
    113         if type(field) == type(0) : # TODO : do something safer 
     116        if type(field) in (type(0), type(0.0)) : # TODO : do something safer 
    114117            typ = "decimal" 
    115118        else :     
  • pykota/trunk/pykota/storages/sql.py

    r967 r976  
    2121# 
    2222# $Log$ 
     23# Revision 1.31  2003/04/30 13:36:40  jalet 
     24# Stupid accounting method was added. 
     25# 
    2326# Revision 1.30  2003/04/27 08:04:15  jalet 
    2427# LDAP storage backend's skeleton added. DOESN'T WORK. 
     
    368371        self.doQuery("UPDATE grouppquota SET datelimit=%s::TIMESTAMP WHERE groupid=%s AND printerid=%s" % (self.doQuote("%04i-%02i-%02i %02i:%02i:%02i" % (datelimit.year, datelimit.month, datelimit.day, datelimit.hour, datelimit.minute, datelimit.second)), self.doQuote(groupid), self.doQuote(printerid))) 
    369372         
    370     def addJobToHistory(self, jobid, userid, printerid, pagecounter, action) : 
     373    def addJobToHistory(self, jobid, userid, printerid, pagecounter, action, jobsize=None) : 
    371374        """Adds a job to the history: (jobid, userid, printerid, last page counter taken from requester).""" 
    372         self.doQuery("INSERT INTO jobhistory (jobid, userid, printerid, pagecounter, action) VALUES (%s, %s, %s, %s, %s)" % (self.doQuote(jobid), self.doQuote(userid), self.doQuote(printerid), self.doQuote(pagecounter), self.doQuote(action))) 
     375        self.doQuery("INSERT INTO jobhistory (jobid, userid, printerid, pagecounter, action, jobsize) VALUES (%s, %s, %s, %s, %s, %s)" % (self.doQuote(jobid), self.doQuote(userid), self.doQuote(printerid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize))) 
    373376        return self.getJobHistoryId(jobid, userid, printerid) # in case jobid is not sufficient 
    374377     
     
    379382    def getPrinterPageCounter(self, printerid) : 
    380383        """Returns the last page counter value for a printer given its id, also returns last username, last jobid and history line id.""" 
    381         result = self.doQuery("SELECT jobhistory.id, jobid, userid, username, pagecounter FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printerid)) 
     384        result = self.doQuery("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printerid)) 
    382385        try : 
    383386            return self.doParseResult(result)[0]