[python-bugzilla] About .logged_in

Pierre-Yves Chibon pingou at pingoured.fr
Mon Nov 24 10:12:19 UTC 2014


Hi,

I have found a small thing that annoys me a little, as an example might make it
easier to explain, here we go:

>>> from bugzilla import Bugzilla
>>> bz = Bugzilla('https://bugzilla.redhat.com/xmlrpc.cgi')
>>> bz.logged_in
False
>>> bug = bz.getbug(123)
>>> bz.logged_in
False
>>> set([com['author'] for com in bug.comments])
set(['steve at ...', 'why_99 at ...', 'jbj at ...'])

Basically, the client authenticates against bugzilla with the token stored on
the file system, but it means that the `.logged_in` method does not actually say
if the user is logged in or not unless we specifically call `.login()`.

I can imagine that we do not know at first is the token stored on the disk is
still valid or not, but maybe could we check after calling bugzilla the first
time if said the result returned allowed to determine is the user is logged in
or not.
For `.getbug()` maybe we could check for the presence of '@' in the `.creator`.
I guess there are other methods where we maybe be able to find out if the user
is logged in or not.

Basically, it would allow then things like:
>>> from bugzilla import Bugzilla
>>> bz = Bugzilla('https://bugzilla.redhat.com/xmlrpc.cgi')
>>> bug = bz.getbug(123)
>>> if not bz.logged_in:
...    bz.login(...)
...    bug = bgz.getbug(123)

I adjusted my code to do
>>> from bugzilla import Bugzilla
>>> bz = Bugzilla('https://bugzilla.redhat.com/xmlrpc.cgi')
>>> bug = bz.getbug(123)
>>> if not '@' in bug.creator:
...    bz.login(...)
...    bug = bgz.getbug(123)

but I thought it might be an idea to have something in python-bugzilla itself
for this.


Thoughts?
Pierre


More information about the python-bugzilla mailing list