Changeset 1147

Show
Ignore:
Timestamp:
10/07/03 16:23:25 (21 years ago)
Author:
jalet
Message:

More work on cache

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r1130 r1147  
    5555# If unset, caching is disabled. Possible values Y/N/YES/NO 
    5656# caching mechanism works with both PostgreSQL and OpenLDAP backends 
    57 # but may be interesting only with OpenLDAP. 
     57# but may be really interesting only with OpenLDAP. 
     58# 
     59# ACTIVATING CACHE IS HEAVILY RECOMMANDED WITH THE LDAP BACKEND ! 
     60# 
    5861storagecaching: No 
    5962 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1144 r1147  
    2222# 
    2323# $Log$ 
     24# Revision 1.32  2003/10/07 14:23:25  jalet 
     25# More work on cache 
     26# 
    2427# Revision 1.31  2003/10/07 09:07:30  jalet 
    2528# Character encoding added to please latest version of Python 
     
    405408        """Returns the user's groups list.""" 
    406409        groups = [] 
    407         result = self.doSearch("(&(objectClass=pykotaGroup)(%s=%s))" % (self.info["groupmembers"], user.Name), [self.info["grouprdn"]], base=self.info["groupbase"]) 
     410        result = self.doSearch("(&(objectClass=pykotaGroup)(%s=%s))" % (self.info["groupmembers"], user.Name), [self.info["grouprdn"], "pykotaGroupName", "pykotaLimitBy"], base=self.info["groupbase"]) 
    408411        if result : 
    409412            for (groupid, fields) in result : 
    410                 groups.append(self.getGroup(fields.get(self.info["grouprdn"])[0])) 
     413                groupname = (fields.get("pykotaGroupName", [None]) or fields.get(self.info["grouprdn"], [None]))[0] 
     414                group = self.getFromCache("GROUPS", groupname) 
     415                if group is None : 
     416                    group = StorageGroup(self, groupname) 
     417                    group.ident = groupid 
     418                    group.LimitBy = fields.get("pykotaLimitBy") 
     419                    if group.LimitBy is not None : 
     420                        group.LimitBy = group.LimitBy[0] 
     421                    group.AccountBalance = 0.0 
     422                    group.LifeTimePaid = 0.0 
     423                    for member in self.getGroupMembers(group) : 
     424                        if member.Exists : 
     425                            group.AccountBalance += member.AccountBalance 
     426                            group.LifeTimePaid += member.LifeTimePaid 
     427                    group.Exists = 1 
     428                    self.cacheEntry("GROUPS", group.Name, group) 
     429                groups.append(group) 
    411430        return groups         
    412431