コード例 #1
0
ファイル: workflow.py プロジェクト: adroullier/nive
    def Allow(self, context, user):
        """
        Checks if the transition can be executed in the current context.

        parameters ::
        
            context: the context object
            user: the current user

        returns True/False        
        """
        # condition
        if self.conditions:
            for c in self.conditions:
                if isinstance(c, basestring):
                    c = ResolveName(c)
                if not c(transition=self, context=context, user=user, values=self.values):
                    return False
        # roles
        if self.roles == WfAllRoles:
            return True
        if user:
            # call registered authentication policy
            groups = effective_principals()
            if groups==None:
                # no pyramid authentication policy activated
                # use custom user lookup
                groups = user.GetGroups(context)
                if context and ILocalGroups.providedBy(context):
                    local = context.GetLocalGroups(unicode(user))
                    groups = list(groups)+list(local)
        else:
            groups = (u"system.Everyone",)
        for r in groups:
            if r in self.process.adminGroups:
                return True
            if r in self.roles:
                return True
        return False
コード例 #2
0
ファイル: test_security.py プロジェクト: adroullier/nive
 def test_principals(self):
     p = effective_principals()
     self.assert_(p==None)