Ticket #12769: ticket12769_insane_but_working_fix.diff

File ticket12769_insane_but_working_fix.diff, 1.1 KB (added by mrts, 15 years ago)
  • django/utils/functional.py

    diff --git a/django/utils/functional.py b/django/utils/functional.py
    index e52ab76..05d5cb6 100644
    a b def lazy(func, *resultclasses):  
    234234            memo[id(self)] = self
    235235            return self
    236236
     237        def __getstate__(self):
     238            import pickle, sys
     239            thismodule = sys.modules[__name__]
     240            setattr(thismodule, '__proxy__', self.__class__)
     241            return {'func': pickle.dumps(self.__func),
     242                    'args': pickle.dumps(self.__args),
     243                    'kw': pickle.dumps(self.__kw),}
     244
     245        def __setstate__(self, state):
     246            import pickle, sys
     247            thismodule = sys.modules[__name__]
     248            setattr(thismodule, '__proxy__', self.__class__)
     249            self.__func = pickle.loads(state['func'])
     250            self.__args = pickle.loads(state['args'])
     251            self.__kw = pickle.loads(state['kw'])
     252
    237253    def __wrapper__(*args, **kw):
    238254        # Creates the proxy object, instead of the actual value.
    239255        return __proxy__(args, kw)
Back to Top