(self, state)
For unpickling a pickled report.
For unpickling a pickled report.
For unpickling a pickled report .
def __setstate__(self, state):
        """
            For unpickling a pickled report.
        """
        logging = get_task_logger(__name__) # logging lis likely to happen within celery.
        self.domain = state.get('domain')
        self.context = state.get('context', {})

        class FakeHttpRequest(object):
            method = 'GET'
            domain = ''
            GET = {}
            META = {}
            couch_user = None
            datespan = None
            can_access_all_locations = None

        request_data = state.get('request')
        request = FakeHttpRequest()
        request.domain = self.domain
        request.GET = request_data.get('GET', {})
        request.META = request_data.get('META', {})
        request.datespan = request_data.get('datespan')
        request.can_access_all_locations = request_data.get('can_access_all_locations')

        try:
            couch_user = CouchUser.get_by_user_id(request_data.get('couch_user'))
            request.couch_user = couch_user
        except Exception as e:
            logging.error("Could not unpickle couch_user from request for report %s. Error: %s" %
                            (self.name, e))
        self.request = request
        self._caching = True
        self.request_params = state.get('request_params')
        self._update_initial_context()
def __setstate__ ( self , state ) : logging = get_task_logger ( __name__ ) # logging lis likely to happen within celery. self . domain = state . get ( 'domain' ) self . context = state . get ( 'context' , { } ) class FakeHttpRequest ( object ) : method = 'GET' domain = '' GET = { } META = { } couch_user = None datespan = None can_access_all_locations = None request_data = state . get ( 'request' ) request = FakeHttpRequest ( ) request . domain = self . domain request . GET = request_data . get ( 'GET' , { } ) request . META = request_data . get ( 'META' , { } ) request . datespan = request_data . get ( 'datespan' ) request . can_access_all_locations = request_data . get ( 'can_access_all_locations' ) try : couch_user = CouchUser . get_by_user_id ( request_data . get ( 'couch_user' ) ) request . couch_user = couch_user except Exception as e : logging . error ( "Could not unpickle couch_user from request for report %s. Error: %s" % ( self . name , e ) ) self . request = request self . _caching = True self . request_params = state . get ( 'request_params' ) self . _update_initial_context ( )