- Timestamp:
- 02/18/04 00:41:48 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r1332 r1348 22 22 # 23 23 # $Log$ 24 # Revision 1.52 2004/02/17 23:41:48 jalet 25 # Preliminary work on low-level LDAP specific cache. 26 # 24 27 # Revision 1.51 2004/02/04 13:24:41 jalet 25 28 # pkprinters can now remove printers from printers groups. … … 229 232 raise PyKotaStorageError, "Unable to connect to LDAP server %s as %s." % (host, user) # TODO : translate 230 233 else : 234 self.ldapcache = {} # low-level cache specific to LDAP backend 231 235 self.closed = 0 232 236 self.tool.logdebug("Database opened (host=%s, dbname=%s, user=%s)" % (host, dbname, user)) … … 273 277 base = base or self.basedn 274 278 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' 276 280 except ldap.LDAPError, msg : 277 281 raise PyKotaStorageError, (_("Search for %s(%s) from %s(scope=%s) returned no answer.") % (key, fields, base, scope)) + " : %s" % str(msg) 278 282 else : 279 283 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 280 287 return result 281 288 282 289 def doAdd(self, dn, fields) : 283 290 """Adds an entry in the LDAP directory.""" 291 # TODO : store into LDAP specific cache 284 292 fields = self.normalizeFields(fields) 285 293 try : … … 293 301 def doDelete(self, dn) : 294 302 """Deletes an entry from the LDAP directory.""" 303 # TODO : delete from LDAP specific cache 295 304 try : 296 305 self.tool.logdebug("QUERY : Delete(%s)" % dn) … … 302 311 """Modifies an entry in the LDAP directory.""" 303 312 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) 304 318 oldentry = self.doSearch("objectClass=*", base=dn, scope=ldap.SCOPE_BASE) 305 319 for (k, v) in fields.items() :