On Sun, Feb 19, 2012 at 12:55:49AM +0100, Eike Welk wrote: > I'm getting unexpected errors in a Python program that uses Launchpadlib. > > When the program wants to change attributes of a bug, it must first read one > attribute of the bug; otherwise the program fails with an exception from deep > inside Launchpadlib. > > I suspect that I use Launchpadlib in an unintended way. What is the right way > to change attributes in Launchpad? Is there an official way to prepare > objects, so that their attributes can be changed? > > Here is an example that illustrates the odd behavior: > > > from launchpadlib.launchpad import Launchpad > launchpad = Launchpad.login_with("bug-repo-syncer", "production")
If you only care about the bug, then instead of this: > lp_task = launchpad.load( > 'https://api.launchpad.net/1.0/bug-repo-syncer/+bug/934181') > lp_bug = lp_task.bug try: lp_bug = launchpad.bugs[934181] lp_task = lp_bug.bug_tasks[0] Alternatively (this is a common idiom): brs = launchpad.projects['bug-repo-syncer'] for lp_task in brs.searchTasks(assignee=launchpad.me): lp_bug = lp_task.bug #... > #Un-commenting this makes the error go away. > #lp_bug = launchpad.load("https://api.launchpad.net/1.0/bugs/934181") > > #Un-commenting this makes the error go away too. > #lp_bug.title > > lp_bug.title = "Test bug" > lp_bug.description = "A bug for testing Launchpadlib." > > > #Fails with: > #Traceback (most recent call last): > # File "lp_problem.py", line 8, in <module> > # lp_bug.title = "Test bug" > # File "/usr/local/lib/python2.7/ > #site-packages/lazr/restfulclient/resource.py", line 692, in __setattr__ > # if not self.lp_has_parameter(name): > # File "/usr/local/lib/python2.7/ > #site-packages/lazr/restfulclient/resource.py", line 206, in lp_has_parameter > # return self._get_external_param_name(param_name) is not None > # File "/usr/local/lib/python2.7/ > #site-packages/lazr/restfulclient/resource.py", line 349, in > # _get_external_param_name > # if self._wadl_resource.get_parameter(name): > # File "/usr/local/lib/python2.7/site-packages/wadllib/application.py", > #line 452, in get_parameter > # definition = self._find_representation_definition(media_type) > # File "/usr/local/lib/python2.7/site-packages/wadllib/application.py", > #line 564, in _find_representation_definition > # "Resource is not bound to any representation, and no media " > #wadllib.application.NoBoundRepresentationError: Resource is not bound to any > # representation, and no media media type was specified. > > > Eike. > > > _______________________________________________ > Mailing list: https://launchpad.net/~launchpad-dev > Post to : launchpad-dev@lists.launchpad.net > Unsubscribe : https://launchpad.net/~launchpad-dev > More help : https://help.launchpad.net/ListHelp _______________________________________________ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp