def iterable_middleware(app):
 def inner(environ, start_response):
  rv = app(environ, start_response)
  class Iterable(object, ):
   def __iter__(self):
    return iter(rv)
   if hasattr(rv, 'close'):
    def close(self):
     rv.close()
  return Iterable()
 return inner

def iterable_middleware ( app ) : def inner ( environ , start_response ) : rv = app ( environ , start_response ) class Iterable ( object , ) : def __iter__ ( self ) : return iter ( rv ) if hasattr ( rv , 'close' ) : def close ( self ) : rv . close ( ) return Iterable ( ) return inner
guarantee that the app returns an iterable .