1.2-alpha.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Backwards-incompatible changes
  2. ==============================
  3. CSRF Protection
  4. ---------------
  5. There have been large changes to the way that CSRF protection works, detailed in
  6. :ref:`the CSRF documentaton <ref-contrib-csrf>`. The following are the major
  7. changes that developers must be aware of:
  8. * ``CsrfResponseMiddleware`` and ``CsrfMiddleware`` have been deprecated, and
  9. will be removed completely in Django 1.4, in favour of a template tag that
  10. should be inserted into forms.
  11. * ``CsrfViewMiddleware`` is included in :setting:`MIDDLEWARE_CLASSES` by
  12. default. This turns on CSRF protection by default, so that views that accept
  13. POST requests need to be written to work with the middleware. Instructions
  14. on how to do this are found in the CSRF docs.
  15. * All of the CSRF has moved from contrib to core (with backwards compatible
  16. imports in the old locations, which are deprecated).
  17. LazyObject
  18. ----------
  19. ``LazyObject`` is an undocumented utility class used for lazily wrapping other
  20. objects of unknown type. In Django 1.1 and earlier, it handled introspection in
  21. a non-standard way, depending on wrapped objects implementing a public method
  22. ``get_all_members()``. Since this could easily lead to name clashes, it has been
  23. changed to use the standard method, involving ``__members__`` and ``__dir__()``.
  24. If you used ``LazyObject`` in your own code, and implemented the
  25. ``get_all_members()`` method for wrapped objects, you need to make the following
  26. changes:
  27. * If your class does not have special requirements for introspection (i.e. you
  28. have not implemented ``__getattr__()`` or other methods that allow for
  29. attributes not discoverable by normal mechanisms), you can simply remove the
  30. ``get_all_members()`` method. The default implementation on ``LazyObject``
  31. will do the right thing.
  32. * If you have more complex requirements for introspection, first rename the
  33. ``get_all_members()`` method to ``__dir__()``. This is the standard method,
  34. from Python 2.6 onwards, for supporting introspection. If you are require
  35. support for Python < 2.6, add the following code to the class::
  36. __members__ = property(lambda self: self.__dir__())