mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Added the ability to pickle and unpickle QuerySets and Query classes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7499 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -99,6 +99,24 @@ class Query(object):
|
||||
memo[id(self)] = result
|
||||
return result
|
||||
|
||||
def __getstate__(self):
|
||||
"""
|
||||
Pickling support.
|
||||
"""
|
||||
obj_dict = self.__dict__.copy()
|
||||
del obj_dict['connection']
|
||||
return obj_dict
|
||||
|
||||
def __setstate__(self, obj_dict):
|
||||
"""
|
||||
Unpickling support.
|
||||
"""
|
||||
self.__dict__.update(obj_dict)
|
||||
# XXX: Need a better solution for this when multi-db stuff is
|
||||
# supported. It's the only class-reference to the module-level
|
||||
# connection variable.
|
||||
self.connection = connection
|
||||
|
||||
def get_meta(self):
|
||||
"""
|
||||
Returns the Options instance (the model._meta) from which to start
|
||||
|
||||
Reference in New Issue
Block a user