#NEWLINE# def render( self ) : #NEWLINE# #INDENT# 'This is the tricky part, whith the rendered_content create a PDF' #NEWLINE# import xhtml2pdf.pisa as pisa #NEWLINE# if ( not self . _is_rendered ) : #NEWLINE# #INDENT# buffer = StringIO ( ) #NEWLINE# pisa . CreatePDF ( self . rendered_content , buffer , link_callback = fetch_resources ) #NEWLINE# pdf = buffer . getvalue ( ) #NEWLINE# buffer . close ( ) #NEWLINE# self . write ( pdf ) #NEWLINE# self [ 'Content-Disposition' ] = ( 'attachment; filename=%s' % ( self . filename , ) ) #NEWLINE# self . _is_rendered = True #NEWLINE# for post_callback in self . _post_render_callbacks : #NEWLINE# #INDENT# post_callback ( self ) #NEWLINE# #UNINDENT# #UNINDENT# return self