#NEWLINE# @ tornado . gen . coroutine #NEWLINE# def portal_alt_scope_accessible( app , scid , uid , world ) : #NEWLINE# #INDENT# 'Check that a given scope is accessible to the player *as an alternate\n    selection*, that is, using the "link instead to..." selector.\n    Raises an exception if not available.\n    ' #NEWLINE# if ( world [ 'instancing' ] != 'standard' ) : #NEWLINE# #INDENT# raise ErrorMessageException ( 'The instance of this portal may not be changed.' ) #NEWLINE# #UNINDENT# scope = ( yield motor . Op ( app . mongodb . scopes . find_one , { #NEWLINE# #INDENT# '_id' : scid , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# if ( not scope ) : #NEWLINE# #INDENT# raise ErrorMessageException ( 'No such scope!' ) #NEWLINE# #UNINDENT# if ( scope [ 'type' ] == 'glob' ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( scope [ 'type' ] == 'pers' ) : #NEWLINE# #INDENT# player = ( yield motor . Op ( app . mongodb . players . find_one , { #NEWLINE# #INDENT# '_id' : uid , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'scid' : 1 , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# if ( scid == player [ 'scid' ] ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# raise ErrorMessageException ( 'You do not have permission to reach this personal scope.' ) #NEWLINE# #UNINDENT# if ( scope [ 'type' ] == 'grp' ) : #NEWLINE# #INDENT# raise ErrorMessageException ( 'You do not have permission to reach this group scope.' ) #NEWLINE# #UNINDENT# raise ErrorMessageException ( 'Scope type not recognized.' )