On 05/28/2014 04:36 PM, Toshio Kuratomi wrote:
The switch to requests in python-bugzilla seems to have broken the
ability
to use python-bugzilla without a persistent cookie store. The configuration
of requests in the code is telling requests not to use cookies at all when
what we want is just for requests to not save the cookies to a file on disk.
The attached patch should fix that.
From 8e6d4179546a084610e583dc6d36bd4d0ade8c1b Mon Sep 17 00:00:00
2001
From: Toshio Kuratomi <toshio(a)fedoraproject.org>
Date: Wed, 28 May 2014 13:32:40 -0700
Subject: [PATCH] If we specify None for cookiefile, then we don't want cookies
saved to disk. They still have to be used within the process though.
---
bugzilla/base.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bugzilla/base.py b/bugzilla/base.py
index 84d4be3..bea7112 100644
--- a/bugzilla/base.py
+++ b/bugzilla/base.py
@@ -181,6 +181,8 @@ class RequestsTransport(Transport):
Transport.__init__(self, use_datetime=False)
self.verbose = debug
+ if cookiejar is None:
+ cookiejar = _build_cookiejar(None)
self._cookiejar = cookiejar
# transport constructor needs full url too, as xmlrpc does not pass
@@ -193,7 +195,7 @@ class RequestsTransport(Transport):
self.request_defaults = {
'cert': sslcafile if self.use_https else None,
- 'cookies': cookiejar if cookiejar else None,
+ 'cookies': cookiejar,
'verify': sslverify,
'headers': {
'Content-Type': 'text/xml',
-- 1.9.3
Hmm. The BugzillaBase class should always be passing a cookiejar object into
RequestsTransport, it's just that if cookiefile=None, the cookiejar isn't
backed by any file and we never save.
The root issue seems to be that bool(cookiejar) == False if the cookiejar is
empty. So in fact only the second hunk is required here (it may be useful for
testing purposes to allow RequestsTransport to indeed disable cookies entirely
so the first bit is not necessary.)
I dropped the first bit, tidyed up the commit message and pushed. Thanks!
- Cole