@tornado.gen.coroutine
def scope_access_level(app, uid, wid, scid):
    scope = yield motor.Op(app.mongodb.scopes.find_one,
                         {'_id':scid},
                         {'type':1, 'level':1})
    if scope['type'] == 'glob':
        world = yield motor.Op(app.mongodb.worlds.find_one,
                               {'_id':wid})
        if world and world['creator'] == uid:
            return ACC_FOUNDER
        return ACC_VISITOR

    if scope['type'] == 'pers' and scope.get('uid', None) == uid:
        return ACC_FOUNDER
    
    res = yield motor.Op(app.mongodb.scopeaccess.find_one,
                         {'uid':uid, 'scid':scid},
                         {'level':1})
    if not res:
        return ACC_VISITOR
    return res.get('level', ACC_VISITOR)
Check the access level of the given player to the given world and
dataset/ETHPy150Open erkyrath/tworld/lib/two/execute.py/scope_access_level