class StorageMgrCookieJar(http.cookiejar.CookieJar):
- def __init__(self, storage_mgr):
+ def __init__(self, storage_mgr, *args):
+ super().__init__(*args)
self.storage_mgr = storage_mgr
def load(self):
if 'cookies' not in self.storage_mgr.keys():
- self.storage_mgr['cookies'] = {}
- self._cookies = self.storage_mgr['cookies']
+ self.storage_mgr['cookies'] = []
+ with self._cookies_lock:
+ self._cookies = {}
+ for dict_ in self.storage_mgr['cookies']:
+ self.set_cookie(http.cookiejar.Cookie(**dict_))
def save(self):
- self.storage_mgr['cookies'] = self._cookies
+ lambda fix_dict = lambda d: {k.strip('_'): v for (k, v) in d.items()}
+ dicts = [fix_dict(c.__dict__) for c in self]
+ self.storage_mgr['cookies'] = dicts
class CookieAuthHandler(urllib.request.HTTPCookieProcessor):