[python-bugzilla] About .logged_in

Arun Babu Neelicattu abn at redhat.com
Mon Nov 24 13:08:23 UTC 2014


Hi Pierre; based on the Users.get() api [1] I have coded a potential solution that will not require a bz.getbug call. The PoC is available at [2].

If this is something useful, I can send a patch.

-arun

[1] https://bugzilla.redhat.com/docs/en/html/api/Bugzilla/WebService/User.html#get
[2] https://github.com/abn/python-bugzilla/commit/4f838927ad26b0c514b2eee2797af88c1eb8fbe6

----- Original Message -----
> From: "Pierre-Yves Chibon" <pingou at pingoured.fr>
> To: python-bugzilla at lists.fedorahosted.org
> Sent: Monday, November 24, 2014 8:12:19 PM
> Subject: [python-bugzilla] About .logged_in
> 
> 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
> _______________________________________________
> python-bugzilla mailing list
> python-bugzilla at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/python-bugzilla
> 


More information about the python-bugzilla mailing list