Changeset 1348

Show
Ignore:
Timestamp:
02/18/04 00:41:48 (21 years ago)
Author:
jalet
Message:

Preliminary work on low-level LDAP specific cache.

Files:
1 modified

Legend:

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

    r1332 r1348  
    2222# 
    2323# $Log$ 
     24# Revision 1.52  2004/02/17 23:41:48  jalet 
     25# Preliminary work on low-level LDAP specific cache. 
     26# 
    2427# Revision 1.51  2004/02/04 13:24:41  jalet 
    2528# pkprinters can now remove printers from printers groups. 
     
    229232            raise PyKotaStorageError, "Unable to connect to LDAP server %s as %s." % (host, user) # TODO : translate 
    230233        else :     
     234            self.ldapcache = {} # low-level cache specific to LDAP backend 
    231235            self.closed = 0 
    232236            self.tool.logdebug("Database opened (host=%s, dbname=%s, user=%s)" % (host, dbname, user)) 
     
    273277            base = base or self.basedn 
    274278            self.tool.logdebug("QUERY : Filter : %s, BaseDN : %s, Scope : %s, Attributes : %s" % (key, base, scope, fields)) 
    275             result = self.database.search_s(base, scope, key, fields) 
     279            result = self.database.search_s(base, scope, key, fields) # TODO : put 'None' instead of 'fields' 
    276280        except ldap.LDAPError, msg :     
    277281            raise PyKotaStorageError, (_("Search for %s(%s) from %s(scope=%s) returned no answer.") % (key, fields, base, scope)) + " : %s" % str(msg) 
    278282        else :      
    279283            self.tool.logdebug("QUERY : Result : %s" % result) 
     284            for (dn, attributes) in result : 
     285                self.tool.logdebug("LDAP cache store (%s)" % dn) 
     286                self.ldapcache[dn] = attributes 
    280287            return result 
    281288             
    282289    def doAdd(self, dn, fields) : 
    283290        """Adds an entry in the LDAP directory.""" 
     291        # TODO : store into LDAP specific cache 
    284292        fields = self.normalizeFields(fields) 
    285293        try : 
     
    293301    def doDelete(self, dn) : 
    294302        """Deletes an entry from the LDAP directory.""" 
     303        # TODO : delete from LDAP specific cache 
    295304        try : 
    296305            self.tool.logdebug("QUERY : Delete(%s)" % dn) 
     
    302311        """Modifies an entry in the LDAP directory.""" 
    303312        try : 
     313            # TODO : take care of, and update LDAP specific cache 
     314            if self.ldapcache.has_key(dn) : 
     315                self.tool.logdebug("LDAP cache hit (%s)" % dn) 
     316            else :     
     317                self.tool.logdebug("LDAP cache miss (%s)" % dn) 
    304318            oldentry = self.doSearch("objectClass=*", base=dn, scope=ldap.SCOPE_BASE) 
    305319            for (k, v) in fields.items() :