Show
Ignore:
Timestamp:
02/13/05 23:02:29 (19 years ago)
Author:
jalet
Message:

Big database structure changes. Upgrade script is now included as well as
the new LDAP schema.
Introduction of the -o | --overcharge command line option to edpykota.
The output of repykota is more complete, but doesn't fit in 80 columns anymore.
Introduction of the new 'maxdenybanners' directive.

Files:
1 modified

Legend:

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

    r2030 r2054  
    2222# 
    2323# $Log$ 
     24# Revision 1.68  2005/02/13 22:02:29  jalet 
     25# Big database structure changes. Upgrade script is now included as well as 
     26# the new LDAP schema. 
     27# Introduction of the -o | --overcharge command line option to edpykota. 
     28# The output of repykota is more complete, but doesn't fit in 80 columns anymore. 
     29# Introduction of the new 'maxdenybanners' directive. 
     30# 
    2431# Revision 1.67  2005/01/18 19:47:50  jalet 
    2532# Big bug fix wrt the datelimit attribute 
     
    276283        self.LifeTimePaid = None 
    277284        self.Email = None 
     285        self.OverCharge = 1.0 
    278286        self.Payments = [] # TODO : maybe handle this smartly for SQL, for now just don't retrieve them 
    279287         
     
    308316            self.LimitBy = limitby 
    309317         
     318    def setOverChargeFactor(self, factor) :     
     319        """Sets the user's overcharging coefficient.""" 
     320        self.parent.writeUserOverCharge(self, factor) 
     321        self.OverCharge = factor 
     322         
    310323    def delete(self) :     
    311324        """Deletes an user from the Quota Storage.""" 
     
    357370        self.PricePerJob = None 
    358371        self.Description = None 
     372        self.Coefficients = None 
    359373         
    360374    def __getattr__(self, name) :     
     
    424438        self.HardLimit = None 
    425439        self.DateLimit = None 
     440        self.WarnCount = None 
    426441         
    427442    def __getattr__(self, name) :     
     
    445460        self.HardLimit = hardlimit 
    446461        self.DateLimit = None 
     462        self.WarnCount = 0 
    447463         
    448464    def setUsage(self, used) : 
     
    454470                self.parent.increaseUserPQuotaPagesCounters(self, vused) 
    455471                self.parent.writeUserPQuotaDateLimit(self, None) 
     472                self.parent.writeUserPQuotaWarnCount(self, 0) 
    456473            except PyKotaStorageError, msg :     
    457474                self.parent.rollbackTransaction() 
     
    465482            self.PageCounter = self.LifePageCounter = vused 
    466483        self.DateLimit = None 
     484        self.WarnCount = 0 
    467485 
     486    def warn(self) : 
     487        """Increases the warn counter for this user quota.""" 
     488        self.parent.increaseUserPQuotaWarnCount(self) 
     489        self.WarnCount = (self.WarnCount or 0) + 1 
     490         
    468491    def reset(self) :     
    469492        """Resets page counter to 0.""" 
     
    482505        totalprice = 0.0     
    483506        if jobsize : 
    484             for upq in [ self ] + self.ParentPrintersUserPQuota : 
    485                 price = (float(upq.Printer.PricePerPage or 0.0) * jobsize) + float(upq.Printer.PricePerJob or 0.0) 
    486                 totalprice += price 
    487         return totalprice     
     507            if self.User.OverCharge != 0.0 :    # optimization, but TODO : beware of rounding errors 
     508                for upq in [ self ] + self.ParentPrintersUserPQuota : 
     509                    price = (float(upq.Printer.PricePerPage or 0.0) * jobsize) + float(upq.Printer.PricePerJob or 0.0) 
     510                    totalprice += price 
     511        if self.User.OverCharge != 1.0 : # TODO : beware of rounding errors 
     512            overcharged = totalprice * self.User.OverCharge         
     513            self.parent.tool.printInfo("Overcharging %s by a factor of %s ===> User %s will be charged for %s units." % (totalprice, self.User.OverCharge, self.User.Name, overcharged)) 
     514            return overcharged 
     515        else :     
     516            return totalprice 
    488517             
    489518    def increasePagesUsage(self, jobsize) : 
     
    589618        self.JobOptions = None 
    590619        self.JobHostName = None 
     620        self.JobMD5Sum = None 
     621        self.JobPages = None 
     622        self.JobBillingCode = None 
    591623         
    592624    def __getattr__(self, name) :