Skip to content

Commit 79f1754

Browse files
djmitchecrobinso
authored andcommitted
Rename BugzillaToken to BugzillaTokenCache
This is a more accurate name, since the object contains tokens, but is not itself a token.
1 parent 2f230c4 commit 79f1754

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

bugzilla/transport.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ class BugzillaError(Exception):
2828
pass
2929

3030

31-
class _BugzillaToken(object):
31+
class _BugzillaTokenCache(object):
32+
"""
33+
Cache for tokens, including, with apologies for the duplicative
34+
terminology, both Bugzilla Tokens and API Keys.
35+
"""
36+
3237
def __init__(self, uri, tokenfilename):
3338
self.tokenfilename = tokenfilename
3439
self.tokenfile = SafeConfigParser()
@@ -63,33 +68,33 @@ def value(self, value):
6368
self.tokenfile.write(tokenfile)
6469

6570
def __repr__(self):
66-
return '<Bugzilla Token :: %s>' % (self.value)
71+
return '<Bugzilla Token Cache :: %s>' % self.value
6772

6873

6974
class _BugzillaServerProxy(ServerProxy):
7075
def __init__(self, uri, tokenfile, *args, **kwargs):
7176
# pylint: disable=super-init-not-called
7277
# No idea why pylint complains here, must be a bug
7378
ServerProxy.__init__(self, uri, *args, **kwargs)
74-
self.token = _BugzillaToken(uri, tokenfile)
79+
self.token_cache = _BugzillaTokenCache(uri, tokenfile)
7580

7681
def clear_token(self):
77-
self.token.value = None
82+
self.token_cache.value = None
7883

7984
def _ServerProxy__request(self, methodname, params):
80-
if self.token.value is not None:
85+
if self.token_cache.value is not None:
8186
if len(params) == 0:
8287
params = ({}, )
8388

8489
if 'Bugzilla_token' not in params[0]:
85-
params[0]['Bugzilla_token'] = self.token.value
90+
params[0]['Bugzilla_token'] = self.token_cache.value
8691

8792
# pylint: disable=maybe-no-member
8893
ret = ServerProxy._ServerProxy__request(self, methodname, params)
8994
# pylint: enable=maybe-no-member
9095

9196
if isinstance(ret, dict) and 'token' in ret.keys():
92-
self.token.value = ret.get('token')
97+
self.token_cache.value = ret.get('token')
9398
return ret
9499

95100

tests/rw_functional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import bugzilla
2727
from bugzilla import Bugzilla
28-
from bugzilla.transport import _BugzillaToken
28+
from bugzilla.transport import _BugzillaTokenCache
2929

3030
import tests
3131

@@ -53,7 +53,7 @@ def _testCookieOrToken(self):
5353
return
5454

5555
if os.path.exists(tf):
56-
token = _BugzillaToken(self.url, tokenfilename=tf)
56+
token = _BugzillaTokenCache(self.url, tokenfilename=tf)
5757
if token.value is not None:
5858
return
5959

0 commit comments

Comments
 (0)