From a97f690e5dbfe9c8d1034a94373da0bedd681814 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 28 Apr 2008 14:14:41 +0000 Subject: 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 --- django/db/models/sql/query.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index bfed984953..7e9fb00418 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -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 -- cgit v1.3