Ejemplo n.º 1
0
def makeuri_contextless(
    request: Request,
    vars_: HTTPVariables,
    filename: Optional[str] = None,
) -> str:
    if not filename:
        filename = requested_file_name(request) + '.py'
    if vars_:
        return filename + "?" + URLEncoder.urlencode_vars(vars_)
    return filename
Ejemplo n.º 2
0
def makeuri(
    request: Request,
    addvars: HTTPVariables,
    filename: Optional[str] = None,
    remove_prefix: Optional[str] = None,
    delvars: Optional[Sequence[str]] = None,
) -> str:
    new_vars = [nv[0] for nv in addvars]
    vars_: HTTPVariables = [(v, val) for v, val in request.itervars()
                            if v[0] != "_" and v not in new_vars and (
                                not delvars or v not in delvars)]
    if remove_prefix is not None:
        vars_ = [i for i in vars_ if not i[0].startswith(remove_prefix)]
    vars_ = vars_ + addvars
    if filename is None:
        filename = URLEncoder.urlencode(requested_file_name(request)) + ".py"
    if vars_:
        return filename + "?" + URLEncoder.urlencode_vars(vars_)
    return filename