mirror of
https://github.com/django/django.git
synced 2025-09-18 08:20:10 +00:00
Fixed #12769, #12924 -- Corrected the pickling of curried and lazy objects, which was preventing queries with translated or related fields from being pickled. And lo, Alex Gaynor didst slayeth the dragon.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12866 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b31b2d4da3
commit
ad5afd6ed2
8 changed files with 49 additions and 53 deletions
|
@ -147,6 +147,12 @@ def lazy(func, *resultclasses):
|
|||
the lazy evaluation code is triggered. Results are not memoized; the
|
||||
function is evaluated on every access.
|
||||
"""
|
||||
# When lazy() is called by the __reduce_ex__ machinery to reconstitute the
|
||||
# __proxy__ class it can't call with *args, so the first item will just be
|
||||
# a tuple.
|
||||
if len(resultclasses) == 1 and isinstance(resultclasses[0], tuple):
|
||||
resultclasses = resultclasses[0]
|
||||
|
||||
class __proxy__(Promise):
|
||||
"""
|
||||
Encapsulate a function call and act as a proxy for methods that are
|
||||
|
@ -162,6 +168,9 @@ def lazy(func, *resultclasses):
|
|||
if self.__dispatch is None:
|
||||
self.__prepare_class__()
|
||||
|
||||
def __reduce_ex__(self, protocol):
|
||||
return (lazy, (self.__func, resultclasses), self.__dict__)
|
||||
|
||||
def __prepare_class__(cls):
|
||||
cls.__dispatch = {}
|
||||
for resultclass in resultclasses:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue