Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
 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(),
         }
Exemplo n.º 6
0
 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(),
     }