def _end_of_life_tween_factory(handler, registry):
 deprecation_msg = 'The service you are trying to connect no longer exists at this location.'
 def eos_tween(request):
  eos_date = registry.settings['eos']
  eos_url = registry.settings['eos_url']
  eos_message = registry.settings['eos_message']
  if (not eos_date):
   return handler(request)
  eos_date = dateparser.parse(eos_date)
  if (eos_date > datetime.now()):
   code = 'soft-eol'
   request.response = handler(request)
  else:
   code = 'hard-eol'
   request.response = errors.http_error(HTTPGone(), errno=errors.ERRORS.SERVICE_DEPRECATED, message=deprecation_msg)
  errors.send_alert(request, eos_message, url=eos_url, code=code)
  return request.response
 return eos_tween

def _end_of_life_tween_factory ( handler , registry ) : deprecation_msg = 'The service you are trying to connect no longer exists at this location.' def eos_tween ( request ) : eos_date = registry . settings [ 'eos' ] eos_url = registry . settings [ 'eos_url' ] eos_message = registry . settings [ 'eos_message' ] if ( not eos_date ) : return handler ( request ) eos_date = dateparser . parse ( eos_date ) if ( eos_date > datetime . now ( ) ) : code = 'soft-eol' request . response = handler ( request ) else : code = 'hard-eol' request . response = errors . http_error ( HTTPGone ( ) , errno = errors . ERRORS . SERVICE_DEPRECATED , message = deprecation_msg ) errors . send_alert ( request , eos_message , url = eos_url , code = code ) return request . response return eos_tween
pyramid tween to handle service end of life .