def require_content(content_type):
 def decorator(f):
  @functools.wraps(f)
  def decorated_function(req):
   if (req.content_type != content_type):
    raise webob.exc.HTTPUnsupportedMediaType((_('The media type %(bad_type)s is not supported, use %(good_type)s') % {'bad_type': (req.content_type or 'None'), 'good_type': content_type}), json_formatter=json_error_formatter)
   else:
    return f(req)
  return decorated_function
 return decorator

def require_content ( content_type ) : def decorator ( f ) : @ functools . wraps ( f ) def decorated_function ( req ) : if ( req . content_type != content_type ) : raise webob . exc . HTTPUnsupportedMediaType ( ( _ ( 'The media type %(bad_type)s is not supported, use %(good_type)s' ) % { 'bad_type' : ( req . content_type or 'None' ) , 'good_type' : content_type } ) , json_formatter = json_error_formatter ) else : return f ( req ) return decorated_function return decorator
decorator to require a content type in a handler .