@tornado.gen.coroutine
def portal_alt_scope_accessible(app, scid, uid, world):
    if (world['instancing'] != 'standard'):
        raise ErrorMessageException('The instance of this portal may not be changed.')

    scope = yield motor.Op(app.mongodb.scopes.find_one,
                            {'_id':scid})
    if not scope:
        raise ErrorMessageException('No such scope!')

    if scope['type'] == 'glob':
        # Global scope is always okay
        return
    if scope['type'] == 'pers':
        player = yield motor.Op(app.mongodb.players.find_one,
                                {'_id':uid},
                                {'scid':1})
        if scid == player['scid']:
            # Your personal scope is always okay
            return
        ### check access level
        raise ErrorMessageException('You do not have permission to reach this personal scope.')
    if scope['type'] == 'grp':
        ### check access level
        raise ErrorMessageException('You do not have permission to reach this group scope.')
    raise ErrorMessageException('Scope type not recognized.')
Check that a given scope is accessible to the player *as an alternate
dataset/ETHPy150Open erkyrath/tworld/lib/two/execute.py/portal_alt_scope_accessible