Files
deb-python-falcon/falcon/util/__init__.py
Henrik Tudborg 1e085393e8 feat(Response) Adding cookie helpers
Added the following new helpers for setting and getting cookies
- set_cookie(name : str, value : str, **cookie_params) -> None
- get_cookie(name : str) -> Morsel
- get_cookies() -> List[Morsel]
- unset_cookie(name : str) -> None
Cookies will - if set - be rendered and merged with headers in
_wsgi_headers. For responses that don't use cookies, there will
no performance hit, except for a single "if cookies is not None:"
check in the _wsgi_headers call.
Implementation use the http.cookies.SimpleCookie (py3) or
Cookie.SimpleCookie (py2) from the stdlib.
Might find extra speed in doing our own implementation.

Fixes #292

feat(Response): cookie fixes from PR discussion

Prev PR here https://github.com/racker/falcon/pull/405

Had an unused import

feat(Request) Adding `cookies` property to request object

Aproach is similar to the `headers` property.
Parse on first access, store a parsed cache, and return a copy.

This should be able to close #292 with the rest of the commits
from PR #405

fix(test): pep8 complaints

docs(cookies): Finishing up cookie docstrings and adding cookie tutorial

doc(cookies): Moving cookie docs to api/cookies.rst

As suggested by @kgriffs
Also added a reference from Request.cookies and Response.set_cookie

style(request): Whitespace nitpick

doc(response): Adding notes about cookies

fix(cookie): Setting a unicode cookie name will now raise if err

If Py2, try to encode name as ascii, if fails, raise KeyError
Try set name to cookie, if fails (invalid name acording to cookie spec)
raise KeyError

style(wording): Fixing bad wording in set_cookie

refactor(TimezoneGMT): Moving class to utils

Had a weird issue when trying to place it in misc.py
where suddenly i couldn't import it. Guessing circular reference,
but couldn't see where.
Moved to utils.time instead. Seems cleaner anyway.

doc(request) Adressing docstring comment

https://github.com/falconry/falcon/pull/405/files#r27823358

doc(cookies): adressing some cookie doc issues
2015-04-11 17:13:51 +02:00

7 lines
179 B
Python

# Hoist misc. utils
from falcon.util.misc import * # NOQA
from falcon.util.time import *
from falcon.util import structures
CaseInsensitiveDict = structures.CaseInsensitiveDict