Changeset 1742

Show
Ignore:
Timestamp:
09/24/04 22:21:50 (20 years ago)
Author:
jalet
Message:

Fixed pykotaAccountBalance object location during creation

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r1741 r1742  
    2222PyKota NEWS : 
    2323 
     24    - 1.20alpha15 : 
     25     
     26        - LDAP pykotaAccountBalance objects were always created 
     27          attached to the pykotaUser objects. This is now 
     28          fixed and the value of balancebase in pykota.conf 
     29          is now correctly used. 
     30           
    2431    - 1.20alpha14 : 
    2532     
  • pykota/trunk/pykota/storage.py

    r1711 r1742  
    2222# 
    2323# $Log$ 
     24# Revision 1.60  2004/09/24 20:21:50  jalet 
     25# Fixed pykotaAccountBalance object location during creation 
     26# 
    2427# Revision 1.59  2004/09/10 21:32:52  jalet 
    2528# Small fixes for incomplete entry intialization 
     
    544547    def getFromCache(self, cachetype, key) : 
    545548        """Tries to extract something from the cache.""" 
     549        entry = None    # just to please pychecker 
    546550        if self.usecache : 
    547551            entry = self.caches[cachetype].get(key) 
     
    550554            else :     
    551555                self.tool.logdebug("Cache miss (%s->%s)" % (cachetype, key)) 
    552             return entry     
     556        return entry     
    553557             
    554558    def cacheEntry(self, cachetype, key, value) :         
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1692 r1742  
    2222# 
    2323# $Log$ 
     24# Revision 1.75  2004/09/24 20:21:50  jalet 
     25# Fixed pykotaAccountBalance object location during creation 
     26# 
    2427# Revision 1.74  2004/09/02 10:09:30  jalet 
    2528# Fixed bug in LDAP user deletion code which didn't correctly delete the user's 
     
    501504                user.LimitBy = user.LimitBy[0] 
    502505            result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments"], base=self.info["balancebase"]) 
    503             if result : 
     506            if not result : 
     507                raise PyKotaStorageError, _("No pykotaAccountBalance object found for user %s. Did you create LDAP entries manually ?") % username 
     508            else : 
    504509                fields = result[0][1] 
    505510                user.idbalance = result[0][0] 
     
    803808        newfields = { 
    804809                       "pykotaUserName" : user.Name, 
    805                        "pykotaLimitBY" : (user.LimitBy or "quota"), 
    806                        "pykotaBalance" : str(user.AccountBalance or 0.0), 
    807                        "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), 
     810                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
    808811                    }    
     812                        
    809813        if user.Email : 
    810814            newfields.update({self.info["usermail"]: user.Email}) 
     
    820824                fields["objectClass"].extend(["pykotaAccount", "pykotaAccountBalance"]) 
    821825                fields.update(newfields) 
     826                fields.update({ "pykotaBalance" : str(user.AccountBalance or 0.0), 
     827                                "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), })    
    822828                self.doModify(dn, fields) 
    823829                mustadd = 0 
     
    830836                 
    831837        if mustadd : 
    832             fields = { self.info["userrdn"] : user.Name, 
    833                        "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"], 
    834                        "cn" : user.Name, 
    835                      }  
     838            if self.info["userbase"] == self.info["balancebase"] :             
     839                fields = { self.info["userrdn"] : user.Name, 
     840                           "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"], 
     841                           "cn" : user.Name, 
     842                           "pykotaBalance" : str(user.AccountBalance or 0.0), 
     843                           "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),  
     844                         }  
     845            else :              
     846                fields = { self.info["userrdn"] : user.Name, 
     847                           "objectClass" : ["pykotaObject", "pykotaAccount"], 
     848                           "cn" : user.Name, 
     849                         }  
    836850            fields.update(newfields)          
    837851            dn = "%s=%s,%s" % (self.info["userrdn"], user.Name, self.info["userbase"]) 
    838852            self.doAdd(dn, fields) 
     853            if self.info["userbase"] != self.info["balancebase"] :             
     854                fields = { self.info["balancerdn"] : user.Name, 
     855                           "objectClass" : ["pykotaObject", "pykotaAccountBalance"], 
     856                           "cn" : user.Name, 
     857                           "pykotaBalance" : str(user.AccountBalance or 0.0), 
     858                           "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),   
     859                         }  
     860                dn = "%s=%s,%s" % (self.info["balancerdn"], user.Name, self.info["balancebase"]) 
     861                self.doAdd(dn, fields) 
     862             
    839863        return self.getUser(user.Name) 
    840864         
  • pykota/trunk/pykota/version.py

    r1740 r1742  
    2222# 
    2323 
    24 __version__ = "1.20alpha14_unofficial" 
     24__version__ = "1.20alpha15_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""