[CMF-checkins] CVS: CMF/CMFCore - ActionInformation.py:1.12 CatalogTool.py:1.37 MemberDataTool.py:1.19 MembershipTool.py:1.29 UndoTool.py:1.11

Chris McDonough chrism@zope.com
Thu, 17 Oct 2002 15:39:06 -0400


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv16445/CMFCore

Modified Files:
	ActionInformation.py CatalogTool.py MemberDataTool.py 
	MembershipTool.py UndoTool.py 
Log Message:
    - Multimodule checkin to convert calls from user.getUserName() to
      user.getId() where appropriate.  User names should not be used
      as immutable references, while user ids should.  The distinction
      is not clearly enforcd in the stock user folder or any current user
      folder implementations, but newer user folder implementations
      will rely upon it.



=== CMF/CMFCore/ActionInformation.py 1.11 => 1.12 ===
--- CMF/CMFCore/ActionInformation.py:1.11	Sat Aug  3 22:38:35 2002
+++ CMF/CMFCore/ActionInformation.py	Thu Oct 17 15:38:35 2002
@@ -189,7 +189,7 @@
         self.portal = portal = aq_parent(aq_inner(tool))
         membership = getToolByName(tool, 'portal_membership')
         self.isAnonymous = membership.isAnonymousUser()
-        self.user_id = membership.getAuthenticatedMember().getUserName()
+        self.user_id = membership.getAuthenticatedMember().getId()
         self.portal_url = portal.absolute_url()
         if folder is not None:
             self.folder_url = folder.absolute_url()


=== CMF/CMFCore/CatalogTool.py 1.36 => 1.37 ===
--- CMF/CMFCore/CatalogTool.py:1.36	Wed Aug 14 11:16:12 2002
+++ CMF/CMFCore/CatalogTool.py	Thu Oct 17 15:38:35 2002
@@ -194,7 +194,7 @@
     def _listAllowedRolesAndUsers( self, user ):
         result = list( user.getRoles() )
         result.append( 'Anonymous' )
-        result.append( 'user:%s' % user.getUserName() )
+        result.append( 'user:%s' % user.getId() )
         return result
 
     # searchResults has inherited security assertions.


=== CMF/CMFCore/MemberDataTool.py 1.18 => 1.19 ===
--- CMF/CMFCore/MemberDataTool.py:1.18	Sat Aug  3 22:31:30 2002
+++ CMF/CMFCore/MemberDataTool.py	Thu Oct 17 15:38:35 2002
@@ -148,7 +148,7 @@
         If possible, returns the Member object that corresponds
         to the given User object.
         '''
-        id = u.getUserName()
+        id = u.getId()
         members = self._members
         if not members.has_key(id):
             # Get a temporary member that might be
@@ -217,7 +217,7 @@
 
     security.declarePublic('getMemberId')
     def getMemberId(self):
-        return self.getUser().getUserName()
+        return self.getUser().getId()
 
     security.declareProtected(SetOwnProperties, 'setProperties')
     def setProperties(self, properties=None, **kw):


=== CMF/CMFCore/MembershipTool.py 1.28 => 1.29 ===
--- CMF/CMFCore/MembershipTool.py:1.28	Mon Oct 14 16:30:25 2002
+++ CMF/CMFCore/MembershipTool.py	Thu Oct 17 15:38:35 2002
@@ -237,7 +237,13 @@
         """
         parent = self.aq_inner.aq_parent
         members =  getattr(parent, 'Members', None)
-        user = self.acl_users.getUser( member_id ).__of__( self.acl_users )
+        
+        user = self.acl_users.getUserById( member_id, None )
+        if user is None:
+            raise ValueError, 'Member %s does not exist' % member_id
+
+        if user is not None:
+            user = user.__of__( self.acl_users )
         
         if members is not None and user is not None:
             f_title = "%s's Home" % member_id
@@ -286,24 +292,26 @@
         if not self.isAnonymousUser():
             acl_users = self.acl_users
             user = _getAuthenticatedUser(self)
-            id = user.getUserName()
+            name = user.getUserName()
+            # this really does need to be the user name, and not the user id,
+            # because we're dealing with authentication credentials
             if hasattr(acl_users.aq_base, 'credentialsChanged'):
                 # Use an interface provided by LoginManager.
-                acl_users.credentialsChanged(user, id, password)
+                acl_users.credentialsChanged(user, name, password)
             else:
                 req = self.REQUEST
                 p = getattr(req, '_credentials_changed_path', None)
                 if p is not None:
                     # Use an interface provided by CookieCrumbler.
                     change = self.restrictedTraverse(p)
-                    change(user, id, password)
+                    change(user, name, password)
 
     security.declareProtected(ManagePortal, 'getMemberById')
     def getMemberById(self, id):
         '''
         Returns the given member.
         '''
-        u = self.acl_users.getUser(id)
+        u = self.acl_users.getUserById(id, None)
         if u is not None:
             u = self.wrapUser(u)
         return u
@@ -326,7 +334,8 @@
         replaced with a set of methods for querying pieces of the
         list rather than the entire list at once.
         '''
-        return self.__getPUS().getUserNames()
+        user_folder = self.__getPUS()
+        return [ x.getId() for x in user_folder.getUsers() ]
     
     security.declareProtected(ManagePortal, 'listMembers')
     def listMembers(self):


=== CMF/CMFCore/UndoTool.py 1.10 => 1.11 ===
--- CMF/CMFCore/UndoTool.py:1.10	Sat Aug  3 22:31:30 2002
+++ CMF/CMFCore/UndoTool.py	Thu Oct 17 15:38:35 2002
@@ -84,10 +84,10 @@
             t['id'] = t['id'].replace('\n', '')
         if not _checkPermission('Manage portal', portal):
             # Filter out transactions done by other members of the portal.
-            user_name = _getAuthenticatedUser(self).getUserName()
+            user_id = _getAuthenticatedUser(self).getId()
             transactions = filter(
-                lambda record, user_name=user_name:
-                split(record['user_name'])[-1] == user_name,
+                lambda record, user_id=user_id:
+                split(record['user_name'])[-1] == user_id,
                 transactions
                 )
         return transactions