Changeset 5441 for main/waeup.sirp/trunk


Ignore:
Timestamp:
16 Aug 2010, 09:40:35 (14 years ago)
Author:
uli
Message:
  • Be more verbose in docstrings.
  • Consider correct field names when authenticating (don't ask for 'login' and 'password' field anymore.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/jambtables/authentication.py

    r5440 r5441  
    4747class ApplicantAccount(Account):
    4848    """An account for applicants.
     49
     50    XXX: Very likely we do not need this at all.
    4951    """
    5052    def __init__(self, reg_no, ac):
     
    7577
    7678class ApplicantPrincipalInfo(object):
     79    """Infos about an applicant principal.
     80    """
    7781    grok.implements(IApplicantPrincipalInfo)
    7882
    7983    # def __init__(self, id, title, description):
    80     def __init__(self, reg_no, access_code):
    81         self.id = '%s-%s' % (reg_no, access_code)
     84    # def __init__(self, reg_no, access_code):
     85    def __init__(self, access_code, jamb_reg_no=None):
     86        self.id = princial_id(access_code, jamb_reg_no)
    8287        self.title = u'Applicant'
    8388        self.description = u'An Applicant'
    8489        self.credentialsPlugin = None
    8590        self.authenticatorPlugin = None
    86         self.reg_no = reg_no
     91        self.reg_no = jamb_reg_no
    8792        self.access_code = access_code
    8893
    8994class ApplicantPrincipal(Principal):
     95    """An applicant principal.
     96
     97    Applicant principals provide an extra `access_code` and `reg_no`
     98    attribute extending ordinary principals.
     99    """
    90100
    91101    grok.implements(IApplicantPrincipal)
     
    104114class AuthenticatedApplicantPrincipalFactory(grok.MultiAdapter):
    105115    """Creates 'authenticated' applicant principals.
     116
     117    Adapts (principal info, request) to an ApplicantPrincipal instance.
     118
     119    This adapter is used by the standard PAU to transform
     120    PrincipalInfos into Principal instances.
    106121    """
    107122    grok.adapts(IApplicantPrincipalInfo, IRequest)
     
    173188        sessionData = session.get(
    174189            'zope.pluggableauth.browserplugins')
    175         access_code = request.get(self.acccesscode_field, None)
     190        access_code = request.get(self.accesscode_field, None)
    176191        jamb_reg_no = request.get(self.jamb_reg_no_field, None)
    177192        credentials = None
     
    211226        if not isinstance(credentials, dict):
    212227            return None
    213         if not 'login' in credentials.keys():
    214             return None
    215         if not 'password' in credentials.keys():
    216             return None
     228        if not 'accesscode' in credentials.keys():
     229            return None
     230        if not 'jambregno' in credentials.keys():
     231            credentials['jambregno'] = None
    217232        return ApplicantPrincipalInfo(
    218             credentials['login'], credentials['password']
     233            credentials['accesscode'], credentials['jambregno']
     234            # credentials['login'], credentials['password']
    219235            )
    220236
     
    222238        """Returns an IPrincipalInfo object for the specified principal id.
    223239
    224         Currently we always return ``None``, indicating, that the principal
    225         could not be found.
     240        This method is used by the stadard PAU to lookup for instance
     241        groups. If a principal belongs to a group, the group is looked
     242        up by the id.  Currently we always return ``None``,
     243        indicating, that the principal could not be found. This also
     244        means, that is has no effect if applicant users belong to a
     245        certain group. They can not gain extra-permissions this way.
    226246        """
    227247        return None
Note: See TracChangeset for help on using the changeset viewer.