[PATCH cube signedrequest V2] Support alternative to Date header

Nicolas Chauvat nicolas.chauvat at logilab.fr
Tue Jun 25 13:53:05 CEST 2019


On Tue, Jun 25, 2019 at 09:42:15AM +0200, Laurent Wouters wrote:
> +def get_replaceable_header_value(request, header_name, default=None):
> +    """
> +    Get the value for a header, looking at prioritized alternatives as required
> +    :param request: The request
> +    :param header_name: The name of the header
> +    :param default: The default value in case the header is not specified
> +    :return: The value of the header, or its alternatives
> +    """
> +    alternates = ALTERNATE_HEADERS[header_name]
> +    if alternates is not None:
> +        # we have a list of prioritized headers
> +        for header_name in alternates:
> +            value = request.get_header(header_name)

IMHO, s/header_name/alt_header_name/ would make things more readable
because there would be no chance to confuse it with the function
argument header_name.

-- 
Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances  



More information about the cubicweb-devel mailing list