We'd like you to use Launchpad web service version "1.0" in Lucid

Leonard Richardson leonard.richardson at canonical.com
Tue Mar 30 15:44:52 BST 2010


Hello,

We on the Launchpad Foundations team have been working to publish
multiple versions of the Launchpad web service simultaneously. This
gives us a way to make major changes to the web service while
maintaining backwards compatibility.

The version of launchpadlib currently in Lucid uses the "beta" version
by default (though you can decide which version you want to access at
runtime). We would like to put launchpadlib version 1.5.8 in Lucid, a
version that uses the "1.0" version by default.

= Background =

Right now we have three versions of the web service: "beta", "1.0", and
"devel". The "beta" version is the one you've been using all this time
(assuming you use the web service at all.) The "devel" version is a
floating development marker similar to "trunk". The "1.0" version is the
one we'd like you to start using.

The "1.0" version has one major difference from "beta". In "beta" there
were a number of operations which did nothing but modify a specific
field. In "1.0", those named operations have been removed, and clients
are expected to modify the appropriate field directly, just as they
would modify a bug's description or any other field.

This is (AFAIK) a complete list of the operations that have been
removed, along with the fields you should modify instead.

bug.setPrivate() -> set bug.private
bug.markAsDuplicate() -> set bug.duplicate_of_link
bugtask.transitionToMilestone() -> set bugtask.milestone_link
bugtask.transitionToImportance() -> set bugtask.importance
bugtask.transitionToStatus() -> set bugtask.status
bugtask.transitionToAssignee() -> set bugtask.assignee_link
bugtask.transitionToTarget() -> set bugtask.target_link
branch.setPrivate() -> set branch.private

= How to port from beta to 1.0 =

It's pretty easy. Add "version=1.0" to your call to the Launchpad
constructor, Launchpad.login_with(), etc. Find any calls to the above
named operations; replace the calls with code that sets the
corresponding attribute and calls lp_save(). Martin Pitt ported apport
to 1.0 fairly easily, in a patch of about 100 lines:

http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/1746

A sample change from the patch:

-task.transitionToTarget(target=self.lp_distro.getSourcePackage(name=report['SourcePackage']))
+task.target=self.lp_distro.getSourcePackage(name=report['SourcePackage'])
+task.lp_save()

Keep in mind two caveats from Martin's experience: 

1. When testing, make sure you're using launchpadlib 1.5.7 or later. A
bug in earlier versions made launchpadlib use the 'beta' service in some
circumstances even when you told it to use another version.

2. Make sure your changed code doesn't trigger bug 551704
(https://bugs.edge.launchpad.net/launchpadlib/+bug/551704). If you grab
an object from a list, modify it, and call lp_save(), make sure you
assign the object to a variable before modifying it rather than indexing
the list twice.

This is bad:

    >>> bug.bug_tasks[2].status = 'Invalid'
    >>> bug.bug_tasks[2].lp_save()

This is good:

    >>> task = bug.bug_tasks[2]
    >>> task.status = 'Invalid'
    >>> task.lp_save()

= Why bother? =

We can't deprecate a version of the web service until the EOL of the
last Ubuntu release to use it by default. If we can get Lucid to use
"1.0", then we on the Launchpad team can deprecate "beta" at Karmic EOL;
otherwise we'll have to wait until Lucid EOL--a very long time.

= Questions for you =

Does this sound doable? What packages need to be ported to 1.0? Can we
do this in time for the Lucid release?

Leonard




More information about the ubuntu-devel mailing list