Mailinglist Archive: opensuse-project (202 mails)

< Previous Next >
[opensuse-project] Re: Regarding Bugzilla's XMLRPC webservice.
On Sun, Jun 19, 2011 at 04:27:13PM +0300, Mihnea Dobrescu-Balaur wrote:
Hello,

I'm practicing searching on the Novell Bugzilla for my GSoC project
and I've stumbled upon a.. problem, I would say.
According to the official documentation[0], I can pass the key 'limit'
with an int value to limit the returned search results. I've tried
doing this but the results I've came across are at least weird (to
me).

[...]
a = bz.query({'summary': 'kde'})
len(a)
3635
a = bz.query({'summary': 'kde', 'limit': 5})
a
[<Bug #489 on https://bugzilla.novell.com/xmlrpc.cgi at 0xe011d0>]
a = bz.query({'summary': 'kde', 'limit': 100})
a
[<Bug #489 on https://bugzilla.novell.com/xmlrpc.cgi at 0xb4c050>,
<Bug #5200 on https://bugzilla.novell.com/xmlrpc.cgi at 0xb4c410>]
a = bz.query({'summary': 'kde', 'limit': 10, 'offset': 10})
a
[]
a = bz.query({'summary': 'kde', 'limit': 100, 'offset': 10})
a
[]


I am using the python-bugzilla module[1], as my mentor has suggested.
You can find some sample code for the usage here[2].

Basically, my question is: how can I limit the number of returned
search results?

Hi Mihnea,

I'm not on opensuse-project, so I don't see responses, if there are
any.

According limit - with my SQL developer experience it smells me like
Mysql LIMIT extension, which works excactly like the limit and offset
clauses. Novell bugzilla runs on Oracle db, where is no LIMIT, so I
thought is is not implemented in Bugzilla/Oracle connector.

But my testing code snipper works well (I use util-linux instead of kde,
but that does not make a difference).

import bugzilla

url = 'https://bugzilla.novell.com/xmlrpc.cgi'
klass = bugzilla.getBugzillaClassForURL(url)
print("loggin in")
bz = klass(url=url)

# full query
q = bz.query({'summary' : 'util-linux'})
# first 10
q10 = bz.query({'summary' : 'util-linux', 'limit' : 10})
# last 8
q_8 = bz.query({'summary' : 'util-linux', 'limit' : 8,
'offset' : len(q)-8})

print("full: %d" % len(q))
print("limited: %d" % len(q10))
print("with offset: %d" % len(q_8))

gave the expected results
$ python test.py
loggin in
full: 48
limited: 10
with offset: 8

Regards
Michal Vyskocil
< Previous Next >