Show
Ignore:
Timestamp:
02/18/06 11:56:29 (18 years ago)
Author:
jerome
Message:

Improved user modification speed by around 15%.

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

Legend:

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

    r2706 r2707  
    10481048        self.doModify(user.ident, newfields) 
    10491049         
     1050        newfields = { "pykotaBalance" : str(user.AccountBalance or 0.0), 
     1051                      "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),  
     1052                    } 
     1053        self.doModify(user.idbalance, newfields) 
     1054         
    10501055    def saveGroup(self, group) : 
    10511056        """Saves the group to the database in a single operation.""" 
     
    10961101        return self.doModify(user.idbalance, fields, flushcache=1)          
    10971102        
    1098     def writeUserAccountBalance(self, user, newbalance, newlifetimepaid=None) :     
    1099         """Sets the new account balance and eventually new lifetime paid.""" 
    1100         fields = { 
    1101                    "pykotaBalance" : str(newbalance), 
    1102                  } 
    1103         if newlifetimepaid is not None : 
    1104             fields.update({ "pykotaLifeTimePaid" : str(newlifetimepaid) }) 
    1105         return self.doModify(user.idbalance, fields)          
    1106              
    11071103    def writeNewPayment(self, user, amount, comment="") : 
    11081104        """Adds a new payment to the payments history.""" 
  • pykota/trunk/pykota/storages/sql.py

    r2706 r2707  
    572572    def saveUser(self, user) :         
    573573        """Saves the user to the database in a single operation.""" 
    574         self.doModify("UPDATE users SET limitby=%s, email=%s, overcharge=%s, description=%s WHERE id=%s" \ 
     574        self.doModify("UPDATE users SET limitby=%s, balance=%s, lifetimepaid=%s, email=%s, overcharge=%s, description=%s WHERE id=%s" \ 
    575575                               % (self.doQuote(user.LimitBy or 'quota'), \ 
     576                                  self.doQuote(user.AccountBalance or 0.0), \ 
     577                                  self.doQuote(user.LifeTimePaid or 0.0), \ 
    576578                                  self.doQuote(user.Email), \ 
    577579                                  self.doQuote(user.OverCharge), \ 
     
    618620        self.doModify("UPDATE users SET balance=balance - %s WHERE id=%s" % (self.doQuote(amount), self.doQuote(user.ident))) 
    619621        
    620     def writeUserAccountBalance(self, user, newbalance, newlifetimepaid=None) :     
    621         """Sets the new account balance and eventually new lifetime paid.""" 
    622         if newlifetimepaid is not None : 
    623             self.doModify("UPDATE users SET balance=%s, lifetimepaid=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(newlifetimepaid), self.doQuote(user.ident))) 
    624         else :     
    625             self.doModify("UPDATE users SET balance=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(user.ident))) 
    626              
    627622    def writeNewPayment(self, user, amount, comment="") : 
    628623        """Adds a new payment to the payments history."""