introspection feature is broken for collections with few elements

Bug #301687 reported by Markus Korn
2
Affects Status Importance Assigned to Milestone
launchpadlib
Triaged
Low
Unassigned

Bug Description

collections with only a few members are missing the next_collection_link and previous_collection_link attribute. This results in a broken introspection feature:

Example:
In [41]: b = launchpad.bugs[123456]

In [42]: dir(b.subscriptions)
Out[42]:
['FIND_ATTRIBUTES',
 'FIND_COLLECTIONS',
 'FIND_ENTRIES',
 'JSON_MEDIA_TYPE',
 '__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__getattr__',
 '__getattribute__',
 '__getitem__',
 '__hash__',
 '__init__',
 '__iter__',
 '__len__',
 '__members__',
 '__methods__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__str__',
 '__weakref__',
 '_convert_dicts_to_entries',
 '_create_bound_resource',
 '_ensure_representation',
 '_get_external_param_name',
 '_get_parameter_names',
 '_get_slice',
 '_root',
 '_transform_resources_to_links',
 '_wadl_resource',
 '_with_url_query_variable_set',
 'entries',
 'entry_links',
 'lp_attributes',
 'lp_collections',
 'lp_entries',
 'lp_get_named_operation',
 'lp_get_parameter',
 'lp_has_parameter',
 'lp_operations',
 'lp_refresh',
 'next',
 'prev',
 'resource_type_link',
 'start',
 'total_size']

In [43]: b.subscriptions.next
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)

/home/markus/<ipython console> in <module>()

/usr/lib/python2.5/site-packages/launchpadlib/resource.pyc in __getattr__(self, attr)
    288 except KeyError:
    289 raise AttributeError("'%s' object has no attribute '%s'"
--> 290 % (self.__class__.__name__, attr))
    291
    292 def _get_external_param_name(self, param_name):

AttributeError: 'Collection' object has no attribute 'next'

In [44]:

The best solution would be if .next could return None in such cases.

Markus

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.