[Zope-CVS] CVS: Products/PluggableAuthService/plugins -
ZODBUserManager.py:1.6.4.1
Jens Vagelpohl
jens at dataflake.org
Tue Oct 19 07:45:10 EDT 2004
Update of /cvs-repository/Products/PluggableAuthService/plugins
In directory cvs.zope.org:/tmp/cvs-serv17979/plugins
Modified Files:
Tag: jens-implement_caching_branch
ZODBUserManager.py
Log Message:
- checkpoint caching stuff on a branch
=== Products/PluggableAuthService/plugins/ZODBUserManager.py 1.6 => 1.6.4.1 ===
--- Products/PluggableAuthService/plugins/ZODBUserManager.py:1.6 Tue Sep 7 14:15:01 2004
+++ Products/PluggableAuthService/plugins/ZODBUserManager.py Tue Oct 19 07:44:40 2004
@@ -17,6 +17,7 @@
$Id$
"""
import sha
+import copy
from AccessControl import ClassSecurityInfo, AuthEncoding
from AccessControl.SecurityManagement import getSecurityManager
@@ -25,6 +26,8 @@
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
+from Products.PluggableAuthService.PASCache import PASCacheable
+from Products.PluggableAuthService.utils import createViewName
from Products.PluggableAuthService.interfaces.plugins \
import IAuthenticationPlugin
from Products.PluggableAuthService.interfaces.plugins \
@@ -35,6 +38,7 @@
from Products.PluggableAuthService.permissions import ManageUsers
from Products.PluggableAuthService.permissions import SetOwnPassword
+
manage_addZODBUserManagerForm = PageTemplateFile(
'www/zuAdd', globals(), __name__='manage_addZODBUserManagerForm' )
@@ -51,7 +55,7 @@
'ZODBUserManager+added.'
% dispatcher.absolute_url())
-class ZODBUserManager( BasePlugin ):
+class ZODBUserManager( BasePlugin, PASCacheable ):
""" PAS plugin for managing users in the ZODB.
"""
@@ -122,6 +126,8 @@
user_info = []
user_ids = []
plugin_id = self.getId()
+ view_name = createViewName('enumerateUsers', id or login)
+
if isinstance( id, str ):
id = [ id ]
@@ -129,6 +135,22 @@
if isinstance( login, str ):
login = [ login ]
+ # Look in the cache first...
+ keywords = copy.deepcopy(kw)
+ keywords.update( { 'id' : id
+ , 'login' : login
+ , '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 exact_match and ( id or login ):
if id:
@@ -159,6 +181,9 @@
if not user_filter or user_filter( info ):
user_info.append( info )
+ # Put the computed value into the cache
+ self.ZCacheable_set(user_info, view_name=view_name, keywords=keywords)
+
return tuple( user_info )
#
@@ -247,6 +272,10 @@
del self._login_to_userid[ login_name ]
del self._userid_to_login[ user_id ]
+ # Also, remove from the cache
+ view_name = createViewName('enumerateUsers', user_id)
+ self.ZCacheable_invalidate(view_name=view_name)
+
security.declarePrivate( 'updateUserPassword' )
def updateUserPassword( self, user_id, login_name, password ):
@@ -272,6 +301,7 @@
,
)
+ BasePlugin.manage_options
+ + PASCacheable.manage_options
)
security.declarePublic( 'manage_widgets' )
More information about the Zope-CVS
mailing list