[Zope-CVS] CVS: Products/PluggableAuthService/plugins - ZODBUserManager.py:1.9.6.1

Zachery Bir zbir at urbanape.com
Fri May 27 14:33:13 EDT 2005


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

Modified Files:
      Tag: zbir_fixing_ids_branch
	ZODBUserManager.py 
Log Message:
Make ZODBUserManager do the right thing with exact match searching.

Hand back a mangled id when enumerated.


=== Products/PluggableAuthService/plugins/ZODBUserManager.py 1.9 => 1.9.6.1 ===
--- Products/PluggableAuthService/plugins/ZODBUserManager.py:1.9	Mon Nov  8 17:35:45 2004
+++ Products/PluggableAuthService/plugins/ZODBUserManager.py	Fri May 27 14:33:02 2005
@@ -156,13 +156,29 @@
         if cached_info is not None:
             return tuple(cached_info)
 
-        if exact_match and ( id or login ):
+        terms = id or login
 
-            if id:
-                user_ids.extend( id )
-            elif login:
-                user_ids.extend( [ self._login_to_userid.get( x )
-                                    for x in login ] )
+        if exact_match:
+            if terms:
+
+                if id:
+                    # if we're doing an exact match based on id, it
+                    # absolutely will have been qualified (if we have a
+                    # prefix), so we can ignore any that don't begin with
+                    # our prefix
+                    id = [ x for x in id if x.startswith(self.prefix) ]
+                    user_ids.extend( [ x[len(self.prefix):] for x in id ] )
+                elif login:
+                    user_ids.extend( [ self._login_to_userid.get( x )
+                                       for x in login ] )
+
+                # we're claiming an exact match search, if we still don't
+                # have anything, better bail.
+                if not user_ids:
+                    return ()
+            else:
+                # insane - exact match with neither login nor id
+                return ()
 
         if user_ids:
             user_filter = None
@@ -177,7 +193,7 @@
                 e_url = '%s/manage_users' % self.getId()
                 qs = 'user_id=%s' % user_id
 
-                info = { 'id' : user_id
+                info = { 'id' : self.prefix + user_id
                        , 'login' : self._userid_to_login[ user_id ]
                        , 'pluginid' : plugin_id
                        , 'editurl' : '%s?%s' % (e_url, qs)



More information about the Zope-CVS mailing list