[Zope-CVS] CVS: Products/PluggableAuthService -
PluggableAuthService.py:1.19.2.2 utils.py:1.3.8.2
Jens Vagelpohl
jens at dataflake.org
Tue Oct 26 10:21:20 EDT 2004
Update of /cvs-repository/Products/PluggableAuthService
In directory cvs.zope.org:/tmp/cvs-serv24678
Modified Files:
Tag: jens-implement_caching_branch
PluggableAuthService.py utils.py
Log Message:
- checkpoint checkin
=== Products/PluggableAuthService/PluggableAuthService.py 1.19.2.1 => 1.19.2.2 ===
--- Products/PluggableAuthService/PluggableAuthService.py:1.19.2.1 Tue Oct 19 07:44:39 2004
+++ Products/PluggableAuthService/PluggableAuthService.py Tue Oct 26 10:20:49 2004
@@ -242,10 +242,7 @@
plugins = self._getOb( 'plugins' )
is_top = self._isTop()
- user_ids = self._extractUserIds( request
- , plugins
- # , cache=self._v_credentials_cache
- )
+ user_ids = self._extractUserIds(request, plugins)
( accessed
, container
, name
@@ -254,10 +251,7 @@
for user_id, login in user_ids:
- user = self._findUser( plugins, user_id, login
- # , cache=self._getUserCache()
- , request=request
- )
+ user = self._findUser(plugins, user_id, login, request=request)
if aq_base( user ) is emergency_user:
@@ -633,7 +627,7 @@
# Helper methods
#
security.declarePrivate( '_extractUserIds' )
- def _extractUserIds( self, request, plugins, cache=None ):
+ def _extractUserIds( self, request, plugins ):
""" request -> [ validated_user_id ]
@@ -641,9 +635,6 @@
a user; accumulate a list of the IDs of such users over all
our authentication and extraction plugins.
"""
- if cache is None:
- cache = {}
-
result = []
user_ids = []
@@ -681,16 +672,13 @@
try:
credentials[ 'extractor' ] = extractor_id # XXX: in key?
items = credentials.items()
- # credentials[ 'extractor' ] = extractor_id # XXX: in key?
items.sort()
- cache_key = tuple( items )
except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
LOG('PluggableAuthService', WARNING,
'Credentials error: %s' % credentials,
error=sys.exc_info())
- cache_key = None
else:
- user_ids = cache.get( cache_key, [] )
+ user_ids = []
if not user_ids:
@@ -718,10 +706,6 @@
user_id)
user_ids.append( (mangled_id, name) )
-
- if cache_key is not None:
- cache[ cache_key ] = user_ids
-
result.extend( user_ids )
if not user_ids:
@@ -730,6 +714,7 @@
if user_id is not None:
result.append( ( user_id, name ) )
+
return result
security.declarePrivate( '_unmangleId' )
@@ -836,8 +821,7 @@
return PropertiedUser( user_id, name ).__of__( self )
security.declarePrivate( '_findUser' )
- def _findUser( self, plugins, user_id, name=None, cache=None
- , request=None ):
+ def _findUser( self, plugins, user_id, name=None, request=None ):
""" user_id -> decorated_user
"""
@@ -905,6 +889,15 @@
criteria[ 'login' ] = login
if criteria:
+ view_name = createViewName('_verifyUser', user_id or login)
+ cached_info = self.ZCacheable_get( view_name=view_name
+ , keywords=criteria
+ , default=None
+ )
+
+ if cached_info is not None:
+ return cached_info
+
enumerators = plugins.listPlugins( IUserEnumerationPlugin )
@@ -913,7 +906,12 @@
info = enumerator.enumerateUsers( **criteria )
if info:
- return self._computeMangledId( info[0] )
+ id = self._computeMangledId( info[0] )
+ # Put the computed value into the cache
+ self.ZCacheable_set( id
+ , view_name=view_name
+ , keywords=criteria
+ )
except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
LOG('PluggableAuthService', WARNING,
=== Products/PluggableAuthService/utils.py 1.3.8.1 => 1.3.8.2 ===
--- Products/PluggableAuthService/utils.py:1.3.8.1 Tue Oct 19 07:44:39 2004
+++ Products/PluggableAuthService/utils.py Tue Oct 26 10:20:49 2004
@@ -143,10 +143,13 @@
return suite
-def createViewName(method_name, user_handle):
+def createViewName(method_name, user_handle=None):
"""
Centralized place for creating the "View Name" that identifies
a ZCacheable record in a RAMCacheManager
"""
- return '%s-%s' % (method_name, user_handle)
+ if not user_handle:
+ return method_name
+ else:
+ return '%s-%s' % (method_name, user_handle)
More information about the Zope-CVS
mailing list