diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2009-10-19 21:48:06 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2009-10-19 21:48:06 +0000 |
| commit | c6e8e5d9f068210d25f501b2aae4192d1c01185c (patch) | |
| tree | 257662728927b461ee73cdd5380deb970f702e92 /docs | |
| parent | 22be3d7612b518268b84ce37d3b20f828efb4b6f (diff) | |
Fixed non-standard introspection support in LazyObject.
LazyObject called a public method ``get_all_members`` on wrapped objects in
order to allow introspection. This could easily cause name clashes with
existing methods on wrapped objects, and so has been changed to use the
standard methods. This could be slightly backwards-incompatible, in obscure
cases, if the undocumented LazyObject has been used externally.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11636 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.2-alpha.txt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/releases/1.2-alpha.txt b/docs/releases/1.2-alpha.txt new file mode 100644 index 0000000000..0df2103486 --- /dev/null +++ b/docs/releases/1.2-alpha.txt @@ -0,0 +1,28 @@ + +Backwards-incompatible changes +============================== + +LazyObject +---------- + +``LazyObject`` is an undocumented utility class used for lazily wrapping other +objects of unknown type. In Django 1.1 and earlier, it handled introspection in +a non-standard way, depending on wrapped objects implementing a public method +``get_all_members()``. Since this could easily lead to name clashes, it has been +changed to use the standard method, involving ``__members__`` and ``__dir__()``. +If you used ``LazyObject`` in your own code, and implemented the +``get_all_members()`` method for wrapped objects, you need to make the following +changes: + + * If your class does not have special requirements for introspection (i.e. you + have not implemented ``__getattr__()`` or other methods that allow for + attributes not discoverable by normal mechanisms), you can simply remove the + ``get_all_members()`` method. The default implementation on ``LazyObject`` + will do the right thing. + + * If you have more complex requirements for introspection, first rename the + ``get_all_members()`` method to ``__dir__()``. This is the standard method, + from Python 2.6 onwards, for supporting introspection. If you are require + support for Python < 2.6, add the following code to the class:: + + __members__ = property(lambda self: self.__dir__()) |
