[Zope-CVS] CVS: Products/PluggableAuthService/plugins - DynamicGroupsPlugin.py:1.3.8.1 ZODBUserManager.py:1.6.4.2

Jens Vagelpohl jens at dataflake.org
Tue Oct 26 10:20:50 EDT 2004


Update of /cvs-repository/Products/PluggableAuthService/plugins
In directory cvs.zope.org:/tmp/cvs-serv24678/plugins

Modified Files:
      Tag: jens-implement_caching_branch
	DynamicGroupsPlugin.py ZODBUserManager.py 
Log Message:
- checkpoint checkin


=== Products/PluggableAuthService/plugins/DynamicGroupsPlugin.py 1.3 => 1.3.8.1 ===
--- Products/PluggableAuthService/plugins/DynamicGroupsPlugin.py:1.3	Thu Aug 12 11:15:54 2004
+++ Products/PluggableAuthService/plugins/DynamicGroupsPlugin.py	Tue Oct 26 10:20:50 2004
@@ -37,6 +37,9 @@
 
 from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
 
+from Products.PluggableAuthService.PASCache import PASCacheable
+from Products.PluggableAuthService.utils import createViewName
+
 
 manage_addDynamicGroupsPluginForm = PageTemplateFile(
         'www/dgpAdd', globals(), __name__= 'manage_addDynamicGroupsPluginForm' )
@@ -55,7 +58,7 @@
                            )
                          )
 
-class DynamicGroupDefinition( SimpleItem, PropertyManager ):
+class DynamicGroupDefinition( SimpleItem, PropertyManager, PASCacheable ):
 
     """ Represent a single dynamic group.
     """
@@ -157,7 +160,7 @@
 InitializeClass( DynamicGroupDefinition )
 
 
-class DynamicGroupsPlugin( Folder, BasePlugin ):
+class DynamicGroupsPlugin( Folder, BasePlugin, PASCacheable ):
 
     """ Define groups via business rules.
 
@@ -210,6 +213,23 @@
         group_info = []
         group_ids = []
         plugin_id = self.getId()
+        view_name = createViewName('enumerateGroups', id)
+
+        # Look in the cache first...
+        keywords = copy.deepcopy(kw)
+        keywords.update( { 'id' : id
+                         , 'exact_match' : exact_match
+                         , 'sort_by' : sort_by
+                         , 'max_results' : max_results
+                         }
+                       )
+        cached_info = self.ZCacheable_get( view_name=view_name
+                                         , keywords=keywords
+                                         , default=None
+                                         )
+
+        if cached_info is not None:
+            return tuple(cached_info)
 
         if isinstance( id, str ):
             id = [ id ]
@@ -239,6 +259,9 @@
                 if info[ 'active' ]:
                     group_info.append( info )
 
+        # Put the computed value into the cache
+        self.ZCacheable_set(group_info, view_name=view_name, keywords=keywords)
+
         return tuple( group_info )
 
     #
@@ -322,6 +345,10 @@
                                      )
 
         self._setObject( group_id, info )
+
+        # This method changes the enumerateGroups return value
+        view_name = createViewName('enumerateGroups')
+        self.ZCacheable_invalidate(view_name=view_name)
             
     security.declareProtected( ManageGroups, 'updateGroup' )
     def updateGroup( self
@@ -354,6 +381,12 @@
 
         if active is not None:
             group.active = active
+
+        # This method changes the enumerateGroups return value
+        view_name = createViewName('enumerateGroups')
+        self.ZCacheable_invalidate(view_name=view_name)
+        view_name = createViewName('enumerateGroups', group_id)
+        self.ZCacheable_invalidate(view_name=view_name)
             
     security.declareProtected( ManageGroups, 'removeGroup' )
     def removeGroup( self, group_id ):
@@ -367,6 +400,12 @@
             raise KeyError, 'Invalid group ID: %s' % group_id
 
         self._delObject( group_id )
+
+        # This method changes the enumerateGroups return value
+        view_name = createViewName('enumerateGroups')
+        self.ZCacheable_invalidate(view_name=view_name)
+        view_name = createViewName('enumerateGroups', group_id)
+        self.ZCacheable_invalidate(view_name=view_name)
 
     #
     #   ZMI


=== Products/PluggableAuthService/plugins/ZODBUserManager.py 1.6.4.1 => 1.6.4.2 ===
--- Products/PluggableAuthService/plugins/ZODBUserManager.py:1.6.4.1	Tue Oct 19 07:44:40 2004
+++ Products/PluggableAuthService/plugins/ZODBUserManager.py	Tue Oct 26 10:20:50 2004
@@ -260,6 +260,10 @@
         self._login_to_userid[ login_name ] = user_id
         self._userid_to_login[ user_id ] = login_name
 
+        # enumerateUsers return value has changed
+        view_name = createViewName('enumerateUsers')
+        self.ZCacheable_invalidate(view_name=view_name)
+
     security.declarePrivate( 'removeUser' )
     def removeUser( self, user_id ):
 
@@ -273,6 +277,8 @@
         del self._userid_to_login[ user_id ]
 
         # Also, remove from the cache
+        view_name = createViewName('enumerateUsers')
+        self.ZCacheable_invalidate(view_name=view_name)
         view_name = createViewName('enumerateUsers', user_id)
         self.ZCacheable_invalidate(view_name=view_name)
 



More information about the Zope-CVS mailing list