-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
Description
I have a growing list of Pando monkey patches in Liberapay that should be moved upstream if possible.
-
Request.source: an IP address that can be used in rate limiting, requires a newwebsite.trusted_proxiesattribute as well as theipaddresspackage for python < 3.3 -
Response.encode_url(url): static method used byResponse.redirect(), doesn't have to be part of a class once moved upstream -
Response.error(code, msg=''): modifies the response and raises it -
Response.success(code=200, msg=''): same as above except thatcodedefaults to 200 -
Response.json(obj, code=200): same as above except thatobjis serialized to JSON and theContent-Typeheader is set toapplication/json -
Response.sanitize_untrusted_url(url): prevents XSS attacks -
Response.redirect(url, code=302, trusted_url=True): raises the response after modifying its code, setting theLocationheader, and sanitizing the URL iftrusted_urlis set toFalse -
Response.render(path, state, **extra): renders the resourcepath(e.g.templates/confirm.spt) withstateplusextraas context, sort of an internal redirect -
Response.set_cookie(key, value, expires=None, httponly=True, path='/'): self-explanatory -
Response.erase_cookie(key, **kw): shortcut forset_cookie()with an empty value and an expiration date in the past -
Response.text: the decoded body of the response, useful in tests
elegaanz and chadwhitacre