CVS: Products/PluggableAuthService/plugins - BasePlugin.py:1.5 ZODBUserManager.py:1.10

Zachery Bir <[email protected]>
Newsgroups gmane.comp.web.zope.public-cvs
Message-ID <[email protected]>
Update of /cvs-repository/Products/PluggableAuthService/plugins
In directory cvs.zope.org:/tmp/cvs-serv14876/plugins

Modified Files:
	BasePlugin.py ZODBUserManager.py 
Log Message:
merging zbir_fixing_ids_branch to the head


=== Products/PluggableAuthService/plugins/BasePlugin.py 1.4 => 1.5 ===
--- Products/PluggableAuthService/plugins/BasePlugin.py:1.4	Sat Nov 20 12:53:44 2004
+++ Products/PluggableAuthService/plugins/BasePlugin.py	Fri May 27 14:55:45 2005
@@ -17,6 +17,7 @@
 $Id$
 """
 from OFS.SimpleItem import SimpleItem
+from OFS.PropertyManager import PropertyManager
 from Acquisition import aq_parent, aq_inner
 from AccessControl import ClassSecurityInfo
 from App.class_init import default__class_init__ as InitializeClass
@@ -26,7 +27,7 @@
 
 from Products.PluggableAuthService.permissions import ManageUsers
 
-class BasePlugin(SimpleItem):
+class BasePlugin(SimpleItem, PropertyManager):
 
     """ Base class for all PluggableAuthService Plugins
     """
@@ -35,22 +36,29 @@
 
     __implements__ = SimpleItem.__implements__
 
-    manage_options = ( ( { 'label': 'Activate', 
+    manage_options = ( ( { 'label': 'Activate',
                            'action': 'manage_activateInterfacesForm', }
                          ,
                        )
                      + SimpleItem.manage_options
+                     + PropertyManager.manage_options
                      )
 
+    prefix = ''
+
+    _properties = (
+        dict(id='prefix', type='string', mode='w',
+             label='Optional Prefix'),)
+
     security.declareProtected( ManageUsers, 'manage_activateInterfacesForm' )
     manage_activateInterfacesForm = PageTemplateFile(
-        'www/bpActivateInterfaces', globals(), 
+        'www/bpActivateInterfaces', globals(),
         __name__='manage_activateInterfacesForm')
 
     security.declareProtected( ManageUsers, 'listInterfaces' )
     def listInterfaces( self ):
         """ For ZMI update of interfaces. """
-        
+
         results = []
 
         for iface in flattenInterfaces( self.__implements__ ):
@@ -73,7 +81,7 @@
         active_interfaces = []
 
         for iface_name in interfaces:
-            active_interfaces.append( plugins._getInterfaceFromName( 
+            active_interfaces.append( plugins._getInterfaceFromName(
                                                 iface_name ) )
 
         pt = plugins._plugin_types


=== Products/PluggableAuthService/plugins/ZODBUserManager.py 1.9 => 1.10 ===
--- Products/PluggableAuthService/plugins/ZODBUserManager.py:1.9	Mon Nov  8 17:35:45 2004
+++ Products/PluggableAuthService/plugins/ZODBUserManager.py	Fri May 27 14:55:45 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)

_______________________________________________
Zope-CVS maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope-cvs

Zope CVS instructions: http://dev.zope.org/CVS
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.