Enable translation import queue approval through API

Bug #671329 reported by David Planella on 2010-11-05
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Ubuntu Translations

Bug Description

The fix for bug 664327 means that the imports queue API can now be used to do a great part of the work in an automated way.

Now import queue maintainers can:

* Read all entries for a specific target (distribution, distro release series, project group, project, product release series, or person)
* Change the paths of entries

As a final request, and in order to fully automate the process and give maintainers full control upon entries without having to depend on the web UI or database surgery, it would be extremely useful to be able to approve entries through API.

This means making the setStatus method [1] work, as right now it does not allow to change the status of an entry. Some more info from an IRC conversation on #launchpad-dev:

<dpm> hi all, could someone give me a hand? I'm trying to use the API to manage the import queue entries in Ubuntu. While on the web UI I can change any entry's status, I don't seem to have the permissions when trying to do it with launchpadlib -> http://pastebin.ubuntu.com/594384/ Perhaps I'm not changing the status the way it's supposed to be done. Any ideas?
<wgrant> dpm: Is import_into set?
<dpm> wgrant, what's import_into? I cannot find it in the api docs, and I did not set it
<wgrant> dpm: An import queue entry can't be approved until it has somewhere to be imported into. I'm not sure you can set that through the API.
<dpm> wgrant, ah so perhaps the setStatus call is missing an import_into parameter, you think?
 (I mean in the api)
 or the import queue entry is missing the attribute
<wgrant> dpm: Well, you'd need to set the target POFile or POTemplate.
<wgrant> Which means we'd need to export those two onto the API, which isn't done yet.
<dpm> ok, thanks wgrant, I think I'll file a bug, then
<henninge> wgrant, dpm: that is correct
<henninge> dpm: but there may be more to it because POTempalte and POFile entries might need to geet created during approval.

This would also mean less work for Launchpad Translations developers and LOSAs, as maintainers would no longer have to resort to them for import queue processing on a great number of entries. This could then be done through the API.


Right now, one of the tasks that takes most of the time from the Ubuntu Translations Coordinators team (UTC) is manual work in the imports queue: approving templates, fixing paths, blocking templates, etc. In the case of big source packages (take KDE or OpenOffice.org), manually processing hundreds of packages is a task that can take several hours or
days, which could be best spent working on community-related aspects -apart from the fact that repetitive manual work is very prone to mistakes, as I've had the pain to experience.

Often, when there really isn't any other option, we resort to the Launchpad Translations developers to fix entries through databasesurgery, but that's still not optimal: it takes both developer and LOSA time, and it is also not without a risk regarding entry data loss or corruption.


[1] https://launchpad.net/+apidoc/devel.html#translation_import_queue_entry

David Planella (dpm) wrote :

As in the previous API bug, I'm also adding a task for the ubuntu-translations project. Not a bug per-se, but as the queue which sees most activity and is most looked after is the Ubuntu one, I'd like the UTC team to be in the loop.

Changed in ubuntu-translations:
status: New → Triaged
importance: Undecided → High
Changed in rosetta:
status: New → Triaged
importance: Undecided → Medium
tags: added: api
David Planella (dpm) wrote :

Here's the example code I've used to test the imports queue API:

In [1]: from launchpadlib.launchpad import Launchpad

In [2]: launchpad = Launchpad.login_with('ul10n-tools', 'staging')

In [3]: ubuntu = launchpad.distributions['ubuntu']
The authorization page:
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.

Waiting to hear from Launchpad about your decision...

In [4]: current = ubuntu.current_series

In [5]: oldest_entries = current.getTranslationImportQueueEntries(file_extension = '.pot', import_status = 'Needs Review')[:10]

In [6]: oldest = oldest_entries[0]

In [7]: print oldest.path

In [8]: print oldest.sourcepackage.name

In [9]: print oldest.status
Needs Review

In [10]: oldest.setStatus(new_status = 'Approved')
Unauthorized Traceback (most recent call last)

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

/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyc in __call__(self, *args, **kwargs)
    556 extra_headers = { 'Content-type' : media_type }
    557 response, content = self.root._browser._request(
--> 558 url, in_representation, http_method, extra_headers=extra_headers)
    560 if response.status == 201:

/usr/lib/python2.7/dist-packages/lazr/restfulclient/_browser.pyc in _request(self, url, data, method, media_type, extra_headers)
    279 error = error_for(response, content)
    280 if error is not None:
--> 281 raise error
    282 return response, content

Unauthorized: HTTP Error 401: Unauthorized
Response headers:
content-length: 0
content-type: text/plain
date: Fri, 15 Apr 2011 07:49:13 GMT
server: zope.server.http (HTTP)
status: 401
vary: Accept,Accept-Encoding
via: 1.1 wildcard.staging.launchpad.net
x-lazr-notifications: []
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Response body:


description: updated
summary: - Make status, productseries and sourcepackage keys writeable in the
- translation_import_queue_entry API entry
+ Enable translation import queue approval through API
Jeroen T. Vermeulen (jtv) wrote :

As others have noted, it's important to check that oldest.import_into is not None when you call setStatus. That's the one check that's done outside of the normal authentication system for this call.

By the way, import_into is not a field you can set — it's computed from other fields. I'm not sure how launchpadlib deals with the need to re-compute it; you may have to re-load the object, which in turn I suppose may run into launchpadlib caching.

But assuming that import_into is not None, and that you authorized launchpadlib to perform write actions on your behalf, and that you are logged in using your normal account (which is privileged to make this change) then that would mean that your user identity is not being passed to the API method.

Curtis Hovey (sinzui) on 2011-09-22
Changed in launchpad:
importance: Medium → Low
summary: - Enable translation import queue approval through API
+ Launchpad: Enable translation import queue approval through API
William Grant (wgrant) on 2013-05-23
summary: - Launchpad: Enable translation import queue approval through API
+ Enable translation import queue approval through API
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers