Logo Search packages:      
Sourcecode: zope-pas version File versions  Download package

def PluggableAuthService-1.4::plugins::DomainAuthHelper::DomainAuthHelper::manage_addMapping (   self,
  user_id = '',
  match_type = '',
  match_string = '',
  username = '',
  roles = [],
  REQUEST = None 
)

Add a mapping for a user 

Definition at line 229 of file DomainAuthHelper.py.

                          :
        """ Add a mapping for a user """
        msg = ''

        if match_type not in (_MATCH_EQUALS, _MATCH_ENDSWITH, _MATCH_REGEX):
            msg = 'Unknown match type %s' % match_type

        if not match_string:
            msg = 'No match string specified'

        if match_type == _MATCH_REGEX:
            try:
                re.compile(match_string, re.IGNORECASE)
            except re.error:
                msg = 'Invalid regular expression %s' % match_string

        if msg:
            if REQUEST is not None:
                return self.manage_map(manage_tabs_message=msg)

            raise ValueError, msg

        record = self._domain_map.get(user_id, [])
        if match_type == _MATCH_REGEX:
            real_match = re.compile(match_string, re.IGNORECASE)
        else:
            real_match = match_string

        match = { 'match_type' : match_type
                , 'match_string' : match_string
                , 'match_real' : real_match
                , 'match_id' : '%s_%s' % (user_id, str(time.time()))
                , 'username' : user_id or username or 'Remote User'
                , 'roles' : roles
                }

        if match not in record:
            record.append(match)
        else:
            msg = 'Match already exists'

        self._domain_map[user_id] = record

        if REQUEST is not None:
            msg = msg or 'Match added.'
            if user_id:
                return self.manage_map(manage_tabs_message=msg)
            else:
                return self.manage_genericmap(manage_tabs_message=msg)


    security.declareProtected(manage_users, 'manage_removeMappings')
    def manage_removeMappings(self, user_id='', match_ids=[], REQUEST=None):


Generated by  Doxygen 1.6.0   Back to index