Changeset 2735 for pykota/trunk/pykota

Show
Ignore:
Timestamp:
02/21/06 16:43:18 (18 years ago)
Author:
jerome
Message:

Completely untested modification stuff...

Location:
pykota/trunk/pykota
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storage.py

    r2733 r2735  
    266266    def setLimits(self, softlimit, hardlimit) :     
    267267        """Sets the soft and hard limit for this quota.""" 
    268         self.parent.writeUserPQuotaLimits(self, softlimit, hardlimit) 
    269268        self.SoftLimit = softlimit 
    270269        self.HardLimit = hardlimit 
    271270        self.DateLimit = None 
    272271        self.WarnCount = 0 
     272        self.isDirty = True 
    273273         
    274274    def setUsage(self, used) : 
     
    276276        vused = int(used) 
    277277        if used.startswith("+") or used.startswith("-") : 
    278             self.parent.beginTransaction() 
    279             try : 
    280                 self.parent.increaseUserPQuotaPagesCounters(self, vused) 
    281                 self.parent.writeUserPQuotaDateLimit(self, None) 
    282                 self.parent.writeUserPQuotaWarnCount(self, 0) 
    283             except PyKotaStorageError, msg :     
    284                 self.parent.rollbackTransaction() 
    285                 raise PyKotaStorageError, msg 
    286             else : 
    287                 self.parent.commitTransaction() 
    288278            self.PageCounter += vused 
    289279            self.LifePageCounter += vused 
    290280        else : 
    291             self.parent.writeUserPQuotaPagesCounters(self, vused, vused) 
    292281            self.PageCounter = self.LifePageCounter = vused 
    293282        self.DateLimit = None 
    294283        self.WarnCount = 0 
     284        self.isDirty = 1 
    295285 
    296286    def incDenyBannerCounter(self) : 
     
    306296    def reset(self) :     
    307297        """Resets page counter to 0.""" 
    308         self.parent.writeUserPQuotaPagesCounters(self, 0, int(self.LifePageCounter or 0)) 
    309298        self.PageCounter = 0 
    310299        self.DateLimit = None 
     300        self.isDirty = True 
    311301         
    312302    def hardreset(self) :     
    313303        """Resets actual and life time page counters to 0.""" 
    314         self.parent.writeUserPQuotaPagesCounters(self, 0, 0) 
    315304        self.PageCounter = self.LifePageCounter = 0 
    316305        self.DateLimit = None 
     306        self.isDirty = True 
    317307         
    318308    def computeJobPrice(self, jobsize) :     
     
    385375                uq = self.parent.getUserPQuota(user, self.Printer) 
    386376                uq.reset() 
    387             self.parent.writeGroupPQuotaDateLimit(self, None) 
     377                uq.save() 
    388378        except PyKotaStorageError, msg :     
    389379            self.parent.rollbackTransaction() 
     
    393383        self.PageCounter = 0 
    394384        self.DateLimit = None 
     385        self.isDirty = True 
    395386         
    396387    def hardreset(self) :     
     
    401392                uq = self.parent.getUserPQuota(user, self.Printer) 
    402393                uq.hardreset() 
    403             self.parent.writeGroupPQuotaDateLimit(self, None) 
     394                uq.save() 
    404395        except PyKotaStorageError, msg :     
    405396            self.parent.rollbackTransaction() 
     
    409400        self.PageCounter = self.LifePageCounter = 0 
    410401        self.DateLimit = None 
     402        self.isDirty = True 
    411403         
    412404    def setDateLimit(self, datelimit) :     
     
    423415    def setLimits(self, softlimit, hardlimit) :     
    424416        """Sets the soft and hard limit for this quota.""" 
    425         self.parent.writeGroupPQuotaLimits(self, softlimit, hardlimit) 
    426417        self.SoftLimit = softlimit 
    427418        self.HardLimit = hardlimit 
    428419        self.DateLimit = None 
     420        self.isDirty = True 
    429421         
    430422    def delete(self) :     
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2726 r2735  
    11141114        return self.doModify(userpquota.ident, fields)          
    11151115         
    1116     def writeUserPQuotaPagesCounters(self, userpquota, newpagecounter, newlifepagecounter) :     
    1117         """Sets the new page counters permanently for a user print quota.""" 
    1118         fields = { 
    1119                    "pykotaPageCounter" : str(newpagecounter), 
    1120                    "pykotaLifePageCounter" : str(newlifepagecounter), 
    1121                    "pykotaDateLimit" : None, 
    1122                    "pykotaWarnCount" : "0", 
    1123                  }   
    1124         return self.doModify(userpquota.ident, fields)          
    1125         
    11261116    def decreaseUserAccountBalance(self, user, amount) :     
    11271117        """Decreases user's account balance from an amount.""" 
     
    12081198            self.doAdd(lastjdn, fields)           
    12091199             
    1210     def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) : 
    1211         """Sets soft and hard limits for a user quota.""" 
     1200    def saveUserPQuota(self, userpquota) : 
     1201        """Saves an user print quota entry.""" 
    12121202        fields = {  
    1213                    "pykotaSoftLimit" : str(softlimit), 
    1214                    "pykotaHardLimit" : str(hardlimit), 
    1215                    "pykotaDateLimit" : "None", 
    1216                    "pykotaWarnCount" : "0", 
     1203                   "pykotaSoftLimit" : str(userpquota.SoftLimit), 
     1204                   "pykotaHardLimit" : str(userpquota.HardLimit), 
     1205                   "pykotaDateLimit" : str(userpquota.DateLimit), 
     1206                   "pykotaWarnCount" : str(userpquota.WarnCount), 
     1207                   "pykotaPageCounter" : str(userpquota.PageCounter), 
     1208                   "pykotaLifePageCounter" : str(userpquota.LifePageCounter), 
    12171209                 } 
    12181210        self.doModify(userpquota.ident, fields) 
     
    12321224        return self.doModify(userpquota.ident, fields)          
    12331225         
    1234     def writeGroupPQuotaLimits(self, grouppquota, softlimit, hardlimit) : 
    1235         """Sets soft and hard limits for a group quota on a specific printer.""" 
     1226    def saveGroupPQuota(self, grouppquota) : 
     1227        """Saves a group print quota entry.""" 
    12361228        fields = {  
    1237                    "pykotaSoftLimit" : str(softlimit), 
    1238                    "pykotaHardLimit" : str(hardlimit), 
    1239                    "pykotaDateLimit" : "None", 
     1229                   "pykotaSoftLimit" : str(grouppquota.SoftLimit), 
     1230                   "pykotaHardLimit" : str(grouppquota.HardLimit), 
     1231                   "pykotaDateLimit" : str(grouppquota.DateLimit), 
    12401232                 } 
    12411233        self.doModify(grouppquota.ident, fields) 
  • pykota/trunk/pykota/storages/sql.py

    r2734 r2735  
    672672        self.doModify("UPDATE userpquota SET pagecounter=pagecounter + %s,lifepagecounter=lifepagecounter + %s WHERE id=%s" % (self.doQuote(nbpages), self.doQuote(nbpages), self.doQuote(userpquota.ident))) 
    673673        
    674     def writeUserPQuotaPagesCounters(self, userpquota, newpagecounter, newlifepagecounter) :     
    675         """Sets the new page counters permanently for a user print quota.""" 
    676         self.doModify("UPDATE userpquota SET pagecounter=%s, lifepagecounter=%s, warncount=0, datelimit=NULL WHERE id=%s" % (self.doQuote(newpagecounter), self.doQuote(newlifepagecounter), self.doQuote(userpquota.ident))) 
    677         
    678674    def saveBillingCode(self, code) :     
    679675        """Saves the billing code to the database.""" 
     
    718714            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" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling), self.doQuote(precomputedsize), self.doQuote(precomputedprice), self.doQuote(printer.LastJob.ident))) 
    719715             
    720     def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) : 
    721         """Sets soft and hard limits for a user quota.""" 
    722         self.doModify("UPDATE userpquota SET softlimit=%s, hardlimit=%s, warncount=0, datelimit=NULL WHERE id=%s" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(userpquota.ident))) 
     716    def saveUserPQuota(self, userpquota) : 
     717        """Saves an user print quota entry.""" 
     718        self.doModify("UPDATE userpquota SET softlimit=%s, hardlimit=%s, warncount=%s, datelimit=%s, pagecounter=%s, lifepagecounter=%s WHERE id=%s" \ 
     719                              % (self.doQuote(userpquota.SoftLimit), \ 
     720                                 self.doQuote(userpquota.HardLimit), \ 
     721                                 self.doQuote(userpquota.WarnCount), \ 
     722                                 self.doQuote(userpquota.DateLimit), \ 
     723                                 self.doQuote(userpquota.PageCounter), \ 
     724                                 self.doQuote(userpquota.LifePageCounter), \ 
     725                                 self.doQuote(userpquota.ident))) 
    723726         
    724727    def writeUserPQuotaWarnCount(self, userpquota, warncount) : 
     
    730733        self.doModify("UPDATE userpquota SET warncount=warncount+1 WHERE id=%s" % self.doQuote(userpquota.ident)) 
    731734         
    732     def writeGroupPQuotaLimits(self, grouppquota, softlimit, hardlimit) : 
    733         """Sets soft and hard limits for a group quota on a specific printer.""" 
    734         self.doModify("UPDATE grouppquota SET softlimit=%s, hardlimit=%s, datelimit=NULL WHERE id=%s" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(grouppquota.ident))) 
     735    def saveGroupPQuota(self, grouppquota) : 
     736        """Saves a group print quota entry.""" 
     737        self.doModify("UPDATE grouppquota SET softlimit=%s, hardlimit=%s, datelimit=%s WHERE id=%s" \ 
     738                              % (self.doQuote(grouppquota.SoftLimit), \ 
     739                                 self.doQuote(grouppquota.HardLimit), \ 
     740                                 self.doQuote(grouppquota.DateLimit), \ 
     741                                 self.doQuote(grouppquota.ident))) 
    735742 
    736743    def writePrinterToGroup(self, pgroup, printer) :