dataflake.org

Home Documentation Software Old Stuff Bug Reporting

Caching for getGroupsForPrincipal (Resolved)

Request LDAPMultiPlugins -- feature request -- by Wichert Akkerman
Posted on Sep 4, 2007 5:51 am
Subscribe

Enter your email address to receive mail on every change to this issue.

Entries (Latest first)


  Resolve by Jens Vagelpohl on Sep 4, 2007 8:29 am
  Thanks for tha patch, Wichert. This is now checked in:

http://svn.dataflake.org/?view=rev&revision=1428

 

  Initial Request by Wichert Akkerman on Sep 4, 2007 5:51 am
  In order to get some extra performance I added caching support for getGroupsForPrincipal. The patch below implements this.

Index: LDAPMultiPlugin.py
===================================================================
--- LDAPMultiPlugin.py (revision 1420)
+++ LDAPMultiPlugin.py (working copy)
@@ -114,6 +114,17 @@
security.declarePrivate('getGroupsForPrincipal')
def getGroupsForPrincipal(self, user, request=None, attr=None):
""" Fulfill GroupsPlugin requirements """
+ view_name = self.getId() + '_getGroupsForPrincipal'
+ criteria = {'id':user.getId(), 'attr':attr}
+
+ cached_info = self.ZCacheable_get(view_name = view_name,
+ keywords = criteria,
+ default = None)
+
+ if cached_info is not None:
+ logger.debug('returning cached results from enumerateUsers')
+ return cached_info
+
acl = self._getLDAPUserFolder()

if acl is None:
@@ -130,9 +141,12 @@

groups = acl.getGroups(ldap_user.getUserDN(), attr=attr)

- return tuple([x[0] for x in groups])
+ result = tuple([x[0] for x in groups])
+ self.ZCacheable_set(result, view_name=view_name, keywords=criteria)

+ return result

+
security.declarePrivate('enumerateUsers')
def enumerateUsers( self
, id=None