Changeset 2478


Ignore:
Timestamp:
11/15/07 16:47:21 (7 years ago)
Author:
cxe5014@…
Message:

Fixed some problems with the fsdMyFolder action that led to pervasive TAL errors when logging in as a non-FSD user. Also changed fsdShowMyFolder and fsdMyProfile to use the same mechanism for testing for an FSD user. This should make FSD safe to play with other membraney products.

Fixes #396

File:
1 edited

Legend:

Unmodified
Added
Removed
  • weblion/FacultyStaffDirectory/trunk/tools/FacultyStaffDirectoryTool.py

    r2449 r2478  
    157157    security.declarePublic('fsdMemberProfile') 
    158158    def fsdMemberProfile(self): 
    159         """Distinguish between a membrane user and a regular acl_users user and 
     159        """Distinguish between an fsd user and a regular acl_users user and 
    160160        return the appropriate link for their 'personal profile' page.  For  
    161161        membrane users, this will be the Person object that defines them.  For acl_users 
     
    163163        """ 
    164164        mt = getToolByName(self, 'portal_membership') 
     165        mb = getToolByName(self, MEMBRANE_TOOL) 
    165166         
    166167        if not mt.isAnonymousUser(): 
    167168            usr = mt.getAuthenticatedMember().getUser() 
    168             if (IMembraneUser.providedBy(usr)): 
    169                 # This is a membrane user, return its url 
    170                 mbt = getToolByName(self, MEMBRANE_TOOL) 
    171                 foundUser = mbt.searchResults(getUserName=usr.getUserName())[0] # grab the first match 
    172                 url = foundUser.getURL() + '/edit' 
    173             else: 
     169            try: 
     170                foundUser = mb.searchResults(getUserName=usr.getUserName())[0] # grab the first match 
     171                if (foundUser.portal_type == 'Person'): 
     172                    # this is an FSD Person , get its url and go there 
     173                    url = foundUser.getURL() + '/edit' 
     174                    return url 
     175                else: 
     176                    portalUrl = getToolByName(self,'portal_url')() 
     177                    url = portalUrl + '/personalize_form' 
     178                    return url 
     179            except IndexError: 
    174180                portalUrl = getToolByName(self,'portal_url')() 
    175181                url = portalUrl + '/personalize_form' 
    176             return url 
     182                return url 
    177183         
    178184    security.declarePublic('fsdMyFolder') 
     
    182188        """ 
    183189        mt = getToolByName(self, 'portal_membership') 
    184          
     190        mb = getToolByName(self, MEMBRANE_TOOL) 
    185191        if not mt.isAnonymousUser(): 
    186192            usr = mt.getAuthenticatedMember().getUser() 
    187             if (IMembraneUser.providedBy(usr)): 
    188                 # This is a membrane user and, thus, a Person. Get its URL and go there: 
    189                 mbt = getToolByName(self, MEMBRANE_TOOL) 
    190                 foundUser = mbt.searchResults(getUserName=usr.getUserName())[0]  # Just grab the first matching user. 
    191                 url = foundUser.getURL() 
    192             else: 
    193                 # This is not a membrane user and should be treated like a regular guy: 
    194                 if (mt.getHomeFolder() is None):  # if no home folder, make one (we disabled this by default in FSD product installation) 
    195                     #createMemberarea(self, minimal=False) 
    196                     pass 
     193            try: 
     194                foundUser = mb.searchResults(getUserName=usr.getUserName())[0] 
     195                if (foundUser.portal_type == 'Person'): 
     196                    # this is an FSD Person , get its url and go there 
     197                    url = foundUser.getURL() 
     198                else: 
     199                    url = mt.getHomeUrl() 
     200                return url 
     201            except IndexError: #this person is not a membrane user and should be treated like a regular guy 
    197202                url = mt.getHomeUrl() 
    198             return url 
     203                return url 
    199204             
    200205    security.declarePublic('fsdShowMyFolder') 
     
    204209        """ 
    205210        mt = getToolByName(self, 'portal_membership') 
     211        mb = getToolByName(self, MEMBRANE_TOOL) 
    206212        if not mt.isAnonymousUser(): 
    207213            usr = mt.getAuthenticatedMember().getUser() 
    208             if (IMembraneUser.providedBy(usr)): 
    209                 # This is a membrane user, so return true in under any circumstance 
    210                 return True 
    211             else: 
     214            try: 
     215                foundUser = mb.searchResults(getUserName=usr.getUserName())[0] 
     216                if (foundUser.portal_type == 'Person'): 
     217                    return True 
     218                else: 
     219                    # this is not a membrane user, so let's check some conditions 
     220                    if (mt.getMemberareaCreationFlag() and (mt.getHomeFolder() is not None)): 
     221                        return True 
     222                    else: 
     223                        return False 
     224            except IndexError: 
    212225                # this is not a membrane user, so let's check some conditions 
    213226                if (mt.getMemberareaCreationFlag() and (mt.getHomeFolder() is not None)): 
    214227                    return True 
    215         return False 
     228                else: 
     229                    return False 
    216230         
    217231registerType(FacultyStaffDirectoryTool, PROJECTNAME) 
Note: See TracChangeset for help on using the changeset viewer.