def test_use_json_serializer_without_encryption_key(): setup_cookie_request() so = get_session(use_cookies=False, type='file', data_dir='./cache', data_serializer='json') so['foo'] = 'bar' so.save() session = get_session(id=so.id, use_cookies=False, type='file', data_dir='./cache', data_serializer='json') assert 'foo' in session serialized_session = open(session.namespace.file, 'rb').read() memory_state = pickle.loads(serialized_session) session_data = b64decode(memory_state.get('session')) data = deserialize(session_data, 'json') assert 'foo' in data
def do_open(self, flags, replace): # If we already loaded the data, don't bother loading it again if self.loaded: self.flags = flags return item = self.cache.get_by_key_name(self.namespace) if not item: self._is_new = True self.hash = {} else: self._is_new = False try: self.hash = pickle.loads(str(item.data)) except (IOError, OSError, EOFError, pickle.PickleError): if self.log_debug: log.debug("Couln't load pickle data, creating new storage") self.hash = {} self._is_new = True self.flags = flags self.loaded = True