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

All Samples(28)  |  Call(17)  |  Derive(0)  |  Import(11)

        def getRoles(container, name, value, default):

    global rolesForPermissionOn  # XXX:  avoid import loop

    if rolesForPermissionOn is None:
        from PermissionRole import rolesForPermissionOn

    roles = getattr(value, '__roles__', _noroles)
    if roles is _noroles:
        if not name or not isinstance(name, basestring):
            return default

        if type(value) is MethodType:
            container = value.im_self

        cls = getattr(container, '__class__', None)
        if cls is None:
            return default
        
        roles = getattr(cls, name+'__roles__', _noroles)
        if roles is _noroles:
            return default

        value = container

    if roles is None or isinstance(roles, tuple_or_list):
        return roles

    # Do not override global variable `rolesForPermissionOn`.
    roles_rolesForPermissionOn = getattr(roles, 'rolesForPermissionOn', None)
    if roles_rolesForPermissionOn is not None:
        roles = roles_rolesForPermissionOn(value)

    return roles
        


src/a/c/AccessControl-3.0.8/src/AccessControl/tests/testZopeSecurityPolicy.py   AccessControl(Download)
    def testGetRolesWithMultiThread(self):
        from AccessControl.ZopeSecurityPolicy import getRoles
 
        class C(object):
            pass
        def loop():
            while 1:
                getRoles(c, None, c.v2, 42)
                if len(mark) > 0:
                    return

Previous  1 | 2