#NEWLINE# def test_defer_link_acquisition_blocking( ) : #NEWLINE# #INDENT# class root ( morepath . App ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# class sub ( morepath . App ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# @ root . path ( path = 'model/{id}' ) #NEWLINE# class Model ( object ) : #NEWLINE# #INDENT# def __init__( self , id ) : #NEWLINE# #INDENT# self . id = id #NEWLINE# #UNINDENT# #UNINDENT# @ root . view ( model = Model ) #NEWLINE# def model_default( self , request ) : #NEWLINE# #INDENT# return 'Hello' #NEWLINE# #UNINDENT# @ sub . path ( path = '' ) #NEWLINE# class SubModel ( object ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# @ sub . view ( model = SubModel ) #NEWLINE# def sub_model_default( self , request ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return request . link ( Model ( 'foo' ) ) #NEWLINE# #UNINDENT# except LinkError : #NEWLINE# #INDENT# return 'link error' #NEWLINE# #UNINDENT# #UNINDENT# @ root . mount ( app = sub , path = 'sub' ) #NEWLINE# def mount_sub( ) : #NEWLINE# #INDENT# return sub ( ) #NEWLINE# #UNINDENT# c = Client ( root ( ) ) #NEWLINE# response = c . get ( '/sub' ) #NEWLINE# assert ( c . body == b'link error' )