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

More work on cache

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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