Collections returned by named operations don't act like other collections

Bug #303414 reported by Markus Korn on 2008-11-29
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
launchpadlib
Low
Unassigned

Bug Description

I tried to use launchpad.load() to directly access the url to get all tasks for a project, but this fails with a ValueError:

In [13]: bughelper = launchpad.projects["bughelper"]

In [14]: t = bughelper.searchTasks()

In [15]: t._wadl_resource.url #can't use t.self_link, but this bug 301683
Out[15]: 'https://api.staging.launchpad.net/beta/bughelper?ws.op=searchTasks'

In [16]: t = launchpad.load(t._wadl_resource.url)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (9, 0))

---------------------------------------------------------------------------
ValueError Traceback (most recent call last)

/media/disk-1/lp_api/dbus_service/<ipython console> in <module>()

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/launchpad.pyc in load(self, url)
     76 if type_link is None:
     77 raise ValueError("Couldn't determine the resource type of %s."
---> 78 % url)
     79 resource_type = self._root._wadl.get_resource_type(type_link)
     80 wadl_resource = WadlResource(self._root._wadl, url, resource_type.tag)

ValueError: Couldn't determine the resource type of https://api.staging.launchpad.net/beta/bughelper?ws.op=searchTasks.

In [17]:

As you can see in the attached file from the cache the "resource_type_link" field is missing

Leonard Richardson (leonardr) wrote :

This is why those collections don't have a self_link (as per bug 301683). It wouldn't do you any good.

Fixing this will require significant changes to the WADL generation.

Changed in launchpadlib:
importance: Undecided → Medium
status: New → Triaged
Leonard Richardson (leonardr) wrote :

I marked bug 274074 as a duplicate of this one because it also has to do with the collections returned by named operations not being "real" collections.

summary: - launchpad.load("[...]/beta/bughelper?ws.op=searchTasks") raises an
- ValueError: Couldn't determine the resource type
+ Collections returned by named operations don't act like other
+ collections
Elliot Murphy (statik) wrote :

I'm writing scripts that want to do a bunch of searchTasks calls to launchpad to get bug counts. because len() doesn't work on the collections returned by searchTasks, I end up needing to iterate over all the tasks in order to get a bug count. this probably generates a lot of excess traffic to launchpad compared to if I could just get a count from the search.

Jonathan Lange (jml) wrote :

Elliot, you might already know about this, but there's a workaround on bug 274074.

Changed in launchpadlib:
importance: Medium → Low
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers