Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(9)  |  Call(7)  |  Derive(0)  |  Import(2)
The security context is an object used internally to the security
machinery. It captures data about the current security context.

src/a/c/AccessControl-3.0.8/src/AccessControl/tests/testZopeSecurityPolicy.py   AccessControl(Download)
from AccessControl.userfolder import UserFolder
from AccessControl.SecurityManagement import SecurityContext
        user = uf.getUserById('joe')
        self.user = user
        context = SecurityContext(user)
        self.context = context
        self.policy = self._makeOne()
    def testOwnerAccess(self):
        self.context = SecurityContext(self.uf.getUserById('theowner'))
        item = self.item
        self.assertPolicyAllows(item, 'public_m')
        self.assertPolicyDenies(item, 'protected_m')
        v = self.policy.checkPermission('View', r_item, context)
        self.assert_(not v, '_View_Permission should deny access to user')
        o_context = SecurityContext(self.uf.getUserById('theowner'))
        v = self.policy.checkPermission('View', r_item, o_context)
        self.assert_(v, '_View_Permission should grant access to theowner')
    def test_checkPermission_respects_proxy_roles(self):
        r_item = self.a.r_item
        context = self.context
        self.failIf(self.policy.checkPermission('View', r_item, context))
        o_context = SecurityContext(self.uf.getUserById('joe'))