#NEWLINE# def render( self , data , accepted_media_type = None , renderer_context = None ) : #NEWLINE# #INDENT# if isinstance ( data , dict ) : #NEWLINE# #INDENT# data = [ data ] #NEWLINE# #UNINDENT# zipname = ( '%s.%s' % ( self . arcdirname , self . format ) ) #NEWLINE# self . set_filename ( zipname , renderer_context ) #NEWLINE# fp = tempfile . TemporaryFile ( suffix = ( '.%s' % self . format ) ) #NEWLINE# with zipfile . ZipFile ( fp , mode = 'w' ) as zf : #NEWLINE# #INDENT# for item in data : #NEWLINE# #INDENT# arcname = os . path . join ( self . arcdirname , self . basename ( item ) ) #NEWLINE# io = item [ 'image' ] #NEWLINE# try : #NEWLINE# #INDENT# zf . writestr ( arcname , io . read ( ) ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# zf . write ( io , arcname = arcname ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# io . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . set_response_length ( fp . tell ( ) , renderer_context ) #NEWLINE# fp . seek ( 0 ) #NEWLINE# return fp