HostedFiles: calling non existing methods raises ValueError instead of AttributeError

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

Bug Description

All other subclasses of 'Resource' raise an AttributeError when calling methods/attributes which are not existing, but HostedFile does not, it raises a ValueError:

In [36]: a = b.attachments[0]

In [37]: a.data.boo
---------------------------------------------------------------------------
<type 'exceptions.ValueError'> Traceback (most recent call last)

/media/disk-1/launchpad-vfs/trunk/<ipython console> in <module>()

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/resource.py in __getattr__(self, attr)
    281 """Try to retrive a named operation or parameter of the given name."""
    282 try:
--> 283 return self.lp_get_parameter(attr)
    284 except KeyError:
    285 pass

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/resource.py in lp_get_parameter(self, param_name)
    183 representation, if the parameter is a link.
    184 """
--> 185 self._ensure_representation()
    186 for suffix in ['_link', '_collection_link']:
    187 param = self._wadl_resource.get_parameter(

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/resource.py in _ensure_representation(self)
    304 representation = self._root._browser.get(self._wadl_resource)
    305 self.__dict__['_wadl_resource'] = self._wadl_resource.bind(
--> 306 representation, self.JSON_MEDIA_TYPE)
    307
    308

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/wadllib/application.py in bind(self, representation, media_type, representation_needs_processing, representation_definition)
    324 representation, media_type,
    325 representation_needs_processing,
--> 326 representation_definition)
    327
    328 def get_representation_definition(self, media_type):

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/wadllib/application.py in __init__(self, application, url, resource_type, representation, media_type, representation_needs_processing, representation_definition)
    261 if media_type == 'application/json':
    262 if representation_needs_processing:
--> 263 self.representation = simplejson.loads(representation)
    264 else:
    265 self.representation = representation

/media/disk-1/launchpad-vfs/trunk/build/bdist.linux-x86_64/egg/simplejson/__init__.py in loads(s, encoding, cls, object_hook, **kw)

/media/disk-1/launchpad-vfs/trunk/build/bdist.linux-x86_64/egg/simplejson/decoder.py in decode(self, s, _w)

/media/disk-1/launchpad-vfs/trunk/build/bdist.linux-x86_64/egg/simplejson/decoder.py in raw_decode(self, s, **kw)

<type 'exceptions.ValueError'>: No JSON object could be decoded

In [38]:

Tags: confusing-ui
Changed in launchpadlib:
importance: Undecided → Medium
status: New → Triaged
Changed in launchpadlib:
importance: Medium → High
Changed in launchpadlib:
importance: High → Low
tags: added: confusing-ui
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.