#NEWLINE# def explain_template_loading_attempts( app , template , attempts ) : #NEWLINE# #INDENT# 'This should help developers understand what failed' #NEWLINE# info = [ ( 'Locating template "%s":' % template ) ] #NEWLINE# total_found = 0 #NEWLINE# blueprint = None #NEWLINE# reqctx = _request_ctx_stack . top #NEWLINE# if ( ( reqctx is not None ) and ( reqctx . request . blueprint is not None ) ) : #NEWLINE# #INDENT# blueprint = reqctx . request . blueprint #NEWLINE# #UNINDENT# for ( idx , ( loader , srcobj , triple ) ) in enumerate ( attempts ) : #NEWLINE# #INDENT# if isinstance ( srcobj , Flask ) : #NEWLINE# #INDENT# src_info = ( 'application "%s"' % srcobj . import_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( srcobj , Blueprint ) : #NEWLINE# #INDENT# src_info = ( 'blueprint "%s" (%s)' % ( srcobj . name , srcobj . import_name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# src_info = repr ( srcobj ) #NEWLINE# #UNINDENT# #UNINDENT# info . append ( ( '% 5d: trying loader of %s' % ( ( idx + 1 ) , src_info ) ) ) #NEWLINE# for line in _dump_loader_info ( loader ) : #NEWLINE# #INDENT# info . append ( ( '       %s' % line ) ) #NEWLINE# #UNINDENT# if ( triple is None ) : #NEWLINE# #INDENT# detail = 'no match' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# detail = ( 'found (%r)' % ( triple [ 1 ] or '<string>' ) ) #NEWLINE# total_found += 1 #NEWLINE# #UNINDENT# info . append ( ( '       -> %s' % detail ) ) #NEWLINE# #UNINDENT# seems_fishy = False #NEWLINE# if ( total_found == 0 ) : #NEWLINE# #INDENT# info . append ( 'Error: the template could not be found.' ) #NEWLINE# seems_fishy = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( total_found > 1 ) : #NEWLINE# #INDENT# info . append ( 'Warning: multiple loaders returned a match for the template.' ) #NEWLINE# seems_fishy = True #NEWLINE# #UNINDENT# #UNINDENT# if ( ( blueprint is not None ) and seems_fishy ) : #NEWLINE# #INDENT# info . append ( ( '  The template was looked up from an endpoint that belongs to the blueprint "%s".' % blueprint ) ) #NEWLINE# info . append ( '  Maybe you did not place a template in the right folder?' ) #NEWLINE# info . append ( '  See http://flask.pocoo.org/docs/blueprints/#templates' ) #NEWLINE# #UNINDENT# app . logger . info ( '\n' . join ( info ) )