#NEWLINE# def process_request( self , request ) : #NEWLINE# #INDENT# '\n        For requests for an image file, we check the local image\n        cache. If present, we return the image file, appending\n        the image metadata in headers. If not present, we pass\n        the request on to the next application in the pipeline.\n        ' #NEWLINE# if ( request . method != 'GET' ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# match = get_images_re . match ( request . path ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# image_id = match . group ( 2 ) #NEWLINE# if ( ( '?' in image_id ) or ( image_id == 'detail' ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if self . cache . is_cached ( image_id ) : #NEWLINE# #INDENT# logger . debug ( _ ( "Cache hit for image '%s'" ) , image_id ) #NEWLINE# image_iterator = self . get_from_cache ( image_id ) #NEWLINE# context = request . context #NEWLINE# try : #NEWLINE# #INDENT# image_meta = registry . get_image_metadata ( context , image_id ) #NEWLINE# if ( not image_meta [ 'size' ] ) : #NEWLINE# #INDENT# image_meta [ 'size' ] = self . cache . get_image_size ( image_id ) #NEWLINE# #UNINDENT# response = webob . Response ( request = request ) #NEWLINE# return self . serializer . show ( response , { #NEWLINE# #INDENT# 'image_iterator' : image_iterator , #NEWLINE# 'image_meta' : image_meta , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except exception . NotFound : #NEWLINE# #INDENT# msg = _ ( ( "Image cache contained image file for image '%s', however the registry did not contain metadata for that image!" % image_id ) ) #NEWLINE# logger . error ( msg ) #NEWLINE# #UNINDENT# #UNINDENT# return None