How to enable/disable a release for a source package recipe using the API

Asked by Philip Muškovac

what I've tried is:

1 lp = Launchpad.login_with("disable_release", "production")
2 neon = lp.people['neon']
3 ubuntu = lp.distributions['ubuntu']
4 recipe = neon.recipes[0] # any that doesn't have raring enabled
5 recipe.distroseries.append(ubuntu.getSeries(name_or_version="raring").self_link)
6 recipe.lp_save()

Looking at recipe.distroseries after line 5 shows that the list now contains raring, but as soon as I run lp_save() the change is reset. What am I doing wrong?

Question information

Language:
English Edit question
Status:
Solved
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Solved by:
Curtis Hovey
Solved:
Last query:
Last reply:
Revision history for this message
Best Curtis Hovey (sinzui) said :
#1

I don't think launchpadlib saw the distroseries list mutate. The attribute is a collection which is evaluated separately from the recipe (It is a separate API call). You want to work with each object separately, and explicitly assign them. Try this;
lp = Launchpad.login_with("disable_release", "production")
neon = lp.people['neon']
ubuntu = lp.distributions['ubuntu']
raring = ubuntu.getSeries(name_or_version="raring").self_link
recipe = neon.recipes[0]
series = recipe.distroseries
series.append(raring)
# Assign the series back to the recipe so that launchpadlib knows there was a change.
recipe.distroseries = series
recipe.lp_save()

Revision history for this message
Philip Muškovac (yofel) said :
#2

Thanks!

That, and using the devel API worked. (distroseries is in fact read-only in 1.0)

Revision history for this message
Philip Muškovac (yofel) said :
#3

Thanks Curtis Hovey, that solved my question.