Ignore:
Timestamp:
20 Nov 2011, 12:02:23 (13 years ago)
Author:
Henrik Bettermann
Message:

Prepare for use of ApplicantPrincipalRoleManager? also in students package.

In the next step I will move the class to the securitypolicy module in students and inherit from the new StudentPrincipalRoleManager? class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/securitypolicy.py

    r7137 r7155  
    3434from zope.securitypolicy.settings import Allow, Deny, Unset
    3535from waeup.sirp.applicants.interfaces import IApplicant
     36#from waeup.sirp.students.securitypolicy import StudentPrincipalRoleManager
    3637
    3738# All components in here have the same context: Applicant instances
     
    4041class ApplicantPrincipalRoleManager(AnnotationPrincipalRoleManager,
    4142                                    grok.Adapter):
     43
    4244    grok.provides(IPrincipalRoleManager)
    4345
    4446    #: The attribute name to lookup for additional roles
    4547    extra_attrib = 'course1'
     48    subcontainer = None
    4649
    4750    #: List of role names to look for in `extra_attrib` and parents.
     
    8689        attributes.
    8790        """
    88         result = super(ApplicantPrincipalRoleManager, self
    89                      ).getRolesForPrincipal(principal_id)
     91        apr_manager = AnnotationPrincipalRoleManager(self._context)
     92        result = apr_manager.getRolesForPrincipal(principal_id)
    9093        if result != []:
    9194            # If there are local roles defined here, no additional
     
    9497        # The principal has no local roles yet. Let's lookup the
    9598        # connected course, dept, etc.
    96         obj = getattr(self._context, self.extra_attrib, None)
     99        if self.subcontainer:
     100            obj = getattr(
     101                self._context[self.subcontainer], self.extra_attrib, None)
     102        else:
     103            obj = getattr(self._context, self.extra_attrib, None)
    97104        # lookup local roles for connected course and all parent
    98105        # objects. This way we fake 'role inheritance'.
Note: See TracChangeset for help on using the changeset viewer.