METADATA 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. Metadata-Version: 2.0
  2. Name: cookies
  3. Version: 2.2.1
  4. Summary: Friendlier RFC 6265-compliant cookie parser/renderer
  5. Home-page: https://github.com/sashahart/cookies
  6. Author: Sasha Hart
  7. Author-email: s@sashahart.net
  8. License: UNKNOWN
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 4 - Beta
  11. Classifier: Environment :: Other Environment
  12. Classifier: Intended Audience :: Developers
  13. Classifier: License :: OSI Approved :: MIT License
  14. Classifier: Programming Language :: Python :: 2.6
  15. Classifier: Programming Language :: Python :: 2.7
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.2
  18. Classifier: Programming Language :: Python :: 3.3
  19. Classifier: Programming Language :: Python :: Implementation :: PyPy
  20. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  21. What is this and what is it for?
  22. --------------------------------
  23. cookies.py is a Python module for working with HTTP cookies: parsing and
  24. rendering 'Cookie:' request headers and 'Set-Cookie:' response headers,
  25. and exposing a convenient API for creating and modifying cookies. It can be
  26. used as a replacement of Python's Cookie.py (aka http.cookies).
  27. Features
  28. --------
  29. * Rendering according to the excellent new RFC 6265
  30. (rather than using a unique ad hoc format inconsistently relating to
  31. unrealistic, very old RFCs which everyone ignored). Uses URL encoding to
  32. represent non-ASCII by default, like many other languages' libraries
  33. * Liberal parsing, incorporating many complaints about Cookie.py barfing
  34. on common cookie formats which can be reliably parsed (e.g. search 'cookie'
  35. on the Python issue tracker)
  36. * Well-documented code, with chapter and verse from RFCs
  37. (rather than arbitrary, undocumented decisions and huge tables of magic
  38. values, as you see in Cookie.py).
  39. * Test coverage at 100%, with a much more comprehensive test suite
  40. than Cookie.py
  41. * Single-source compatible with the following Python versions:
  42. 2.6, 2.7, 3.2, 3.3 and PyPy (2.7).
  43. * Cleaner, less surprising API::
  44. # old Cookie.py - this code is all directly from its docstring
  45. >>> from Cookie import SmartCookie
  46. >>> C = SmartCookie()
  47. >>> # n.b. it's "smart" because it automatically pickles Python objects,
  48. >>> # which is actually quite stupid for security reasons!
  49. >>> C["rocky"] = "road"
  50. >>> C["rocky"]["path"] = "/cookie"
  51. >>> # So C["rocky"] is a string, except when it's a dict...
  52. >>> # and why do I have to write [""] to access a fixed set of attrs?
  53. >>> # Look at the atrocious way I render out a request header:
  54. >>> C.output(attrs=[], header="Cookie:")
  55. 'Cookie: rocky=road'
  56. # new cookies.py
  57. >>> from cookies import Cookies, Cookie
  58. >>> cookies = Cookies(rocky='road')
  59. >>> # Can also write explicitly: cookies['rocky'] = Cookie['road']
  60. >>> cookies['rocky'].path = "/cookie"
  61. >>> cookies.render_request()
  62. 'rocky=road'
  63. * Friendly to customization, extension, and reuse of its parts.
  64. Unlike Cookie.py, it doesn't lock all implementation inside its own classes
  65. (forcing you to write ugly wrappers as Django, Trac, Werkzeug/Flask, web.py
  66. and Tornado had to do). You can suppress minor parse exceptions with
  67. parameters rather than subclass wrappers. You can plug in your own parsers,
  68. renderers and validators for new or existing cookie attributes. You can
  69. render the data out in a dict. You can easily use the underlying imperative
  70. API or even lift the parser's regexps for your own parser or project. They
  71. are very well documented and relate directly to RFCs, so you know exactly
  72. what you are getting and why. It's MIT-licensed so do
  73. what you want (but I'd love to know what use you are getting from it!)
  74. * One file, so you can just drop cookies.py into your project if you like
  75. * MIT license, so you can use it in whatever you want with no strings
  76. Things this is not meant to do
  77. ------------------------------
  78. While this is intended to be a good module for handling cookies, it does not
  79. even try to do any of the following:
  80. * Maintain backward compatibility with Cookie.py, which would mean
  81. inheriting its confusions and bugs
  82. * Implement RFCs 2109 or 2965, which have always been ignored by almost
  83. everyone and are now obsolete as well
  84. * Handle every conceivable output from terrible legacy apps, which is not
  85. possible to do without lots of silent data loss and corruption (the
  86. parser does try to be liberal as possible otherwise, though)
  87. * Provide a means to store pickled Python objects in cookie values
  88. (that's a big security hole)
  89. This doesn't compete with the cookielib (http.cookiejar) module in the Python
  90. standard library, which is specifically for implementing cookie storage and
  91. similar behavior in an HTTP client such as a browser. Things cookielib does
  92. that this doesn't:
  93. * Write to or read from browsers' cookie stores or other proprietary
  94. formats for storing cookie data in files
  95. * Handle the browser/client logic like deciding which cookies to send or
  96. discard, etc.
  97. If you are looking for a cookie library but neither this one nor cookielib
  98. will help, you might also consider the implementations in WebOb or Bottle.