dataflake.org

Home Documentation Software Old Stuff Bug Reporting

Add Entry to: Caching for getGroupsForPrincipal (Resolved)

Issue Caching for getGroupsForPrincipal (feature request)
Posted 2007/09/04 by Wichert Akkerman
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


Full name
Email address