#NEWLINE# def pdf( filename = None , content_type = 'application/pdf' ) : #NEWLINE# #INDENT# def entangle( func ) : #NEWLINE# #INDENT# def decorated( func , * args , **kw ) : #NEWLINE# #INDENT# def kwpop( default , * names ) : #NEWLINE# #INDENT# for name in names : #NEWLINE# #INDENT# if ( name in kw ) : #NEWLINE# #INDENT# return kw . pop ( name ) #NEWLINE# #UNINDENT# #UNINDENT# return default #NEWLINE# #UNINDENT# output = func ( * args , ** kw ) #NEWLINE# dst = StringIO . StringIO ( ) #NEWLINE# result = pisa . CreatePDF ( StringIO . StringIO ( output ) , dst ) #NEWLINE# if ( not result . err ) : #NEWLINE# #INDENT# cherrypy . response . headers [ 'Content-Type' ] = content_type #NEWLINE# if filename : #NEWLINE# #INDENT# cherrypy . response . headers [ 'Content-Disposition' ] = ( 'attachment; filename=' + filename ) #NEWLINE# #UNINDENT# output = dst . getvalue ( ) #NEWLINE# #UNINDENT# return output #NEWLINE# #UNINDENT# return decorated #NEWLINE# #UNINDENT# return weak_signature_decorator ( entangle )