コード例 #1
0
ファイル: policy.py プロジェクト: l1ph0x/schooltool-2
    def checkPermission(self, permission, obj):
        """Return True if principal has permission on object."""

        # Check the generic, interface-independent permissions.
        factories = getCrowdsUtility().getFactories(permission, None)
        if factories:
            return self.checkCrowds(factories, obj)

        # No quick method worked, look up the crowd by adaptation.
        return self.checkByAdaptation(permission, obj)
コード例 #2
0
ファイル: policy.py プロジェクト: achouhans/schooltool-2.8.5
    def checkPermission(self, permission, obj):
        """Return True if principal has permission on object."""

        # Check the generic, interface-independent permissions.
        factories = getCrowdsUtility().getFactories(permission, None)
        if factories:
            return self.checkCrowds(factories, obj)

        # No quick method worked, look up the crowd by adaptation.
        return self.checkByAdaptation(permission, obj)
コード例 #3
0
ファイル: policy.py プロジェクト: l1ph0x/schooltool-2
    def checkPermissionCrowds(self, permission, obj):
        """Check object-independent crowds."""
        factories = getCrowdsUtility().getFactories(permission, None)
        if not factories:
            return None

        for participation in self.participations:
            for factory in factories:
                crowd = factory(obj)
                if crowd.contains(participation.principal):
                    self.cache(participation, permission, obj, True)
                    return True
            self.cache(participation, permission, obj, False)
        return False
コード例 #4
0
ファイル: policy.py プロジェクト: achouhans/schooltool-2.8.5
    def checkPermissionCrowds(self, permission, obj):
        """Check object-independent crowds."""
        factories = getCrowdsUtility().getFactories(permission, None)
        if not factories:
            return None

        for participation in self.participations:
            for factory in factories:
                crowd = factory(obj)
                if crowd.contains(participation.principal):
                    self.cache(participation, permission, obj, True)
                    return True
            self.cache(participation, permission, obj, False)
        return False
コード例 #5
0
ファイル: control.py プロジェクト: achouhans/schooltool-2.8.5
 def legends(self):
     # XXX: hacky legend builder (for eye-candy)
     factories = getCrowdsUtility().factories
     crowd = factories['administration'](None)
     description = getCrowdDescription(crowd, None, None)
     if description is None:
         return
     collection = queryMultiAdapter(
         (description, None, self.request,
          description.crowd, description.action, description.group),
         default=None)
     if collection is None:
         return
     yield {
         'idx': '1',
         'description': AdministrationSnippets.description,
         'href': 'legend_administration',
         'snippets': collection.snippets(),
         }
コード例 #6
0
ファイル: control.py プロジェクト: l1ph0x/schooltool-2
 def legends(self):
     # XXX: hacky legend builder (for eye-candy)
     factories = getCrowdsUtility().factories
     crowd = factories['administration'](None)
     description = getCrowdDescription(crowd, None, None)
     if description is None:
         return
     collection = queryMultiAdapter(
         (description, None, self.request, description.crowd,
          description.action, description.group),
         default=None)
     if collection is None:
         return
     yield {
         'idx': '1',
         'description': AdministrationSnippets.description,
         'href': 'legend_administration',
         'snippets': collection.snippets(),
     }