Merge lp:~adiroiban/launchpad/bug-527728 into lp:launchpad

Proposed by Adi Roiban
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~adiroiban/launchpad/bug-527728
Merge into: lp:launchpad
Diff against target: 100 lines (+28/-5)
3 files modified
lib/lp/registry/interfaces/sourcepackage.py (+5/-0)
lib/lp/registry/model/sourcepackage.py (+9/-1)
lib/lp/registry/stories/webservice/xx-source-package.txt (+14/-4)
To merge this branch: bzr merge lp:~adiroiban/launchpad/bug-527728
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+20456@code.launchpad.net

Commit message

Export latest_published_component_name in the ISourcePackage API.

To post a comment you must log in.
Revision history for this message
Adi Roiban (adiroiban) wrote :

= Bug 527728 =

It looks like the source_package is already exported in API (https://api.launchpad.net/+apidoc/#source_package).

To help with translation reporting tasks (https://dev.launchpad.net/Translations/Specs/ReportingAPI) it would be nice to also have the component name for a source package.

== Proposed fix ==
Add compoment_name in the list of exported attributes for ISourcePackage

== Pre-implementation notes ==
Sinzui suggest exporting the compoment_name as latest_published_component_name, since this is the flattening export for latest_published_component

== Implementation details ==

I don't know how to get rid of those lazr.restful lint warning.
Any suggestion is much appreciated.

== Tests ==
lp-test -t source-package.txt

== Demo and Q/A ==
The Ubuntu Hoary source package is exported via API at:
https://launchpad.dev/api/beta/ubuntu/hoary/+source/evolution

The list of attributes should include the „component_name” and it should match the component name displayed at https://launchpad.dev/ubuntu/lucid/+source/evolution

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/registry/interfaces/sourcepackage.py
  lib/lp/registry/model/sourcepackage.py
  lib/lp/registry/stories/webservice/xx-source-package.txt

== Pylint notices ==

lib/lp/registry/interfaces/sourcepackage.py
    21: [F0401] Unable to import 'lazr.enum' (No module named enum)
    27: [F0401] Unable to import 'lazr.restful.fields' (No module named restful)
    28: [F0401] Unable to import 'lazr.restful.declarations' (No module named restful)
    188: [C0322, ISourcePackage.getBranch] Operator not preceded by a space
    vocabulary=DBEnumeratedType))
    ^

    @operation_returns_entry(Interface)
    @export_read_operation()
    def getBranch(pocket):
    206: [C0322, ISourcePackage.setBranch] Operator not preceded by a space
    vocabulary=DBEnumeratedType),
    ^
    branch=Reference(Interface, title=_("Branch"), required=False))
    @call_with(registrant=REQUEST_USER)
    @export_write_operation()
    def setBranch(pocket, branch, registrant):

Revision history for this message
Brad Crittenden (bac) wrote :

Hi Adi,

Thanks for this work. Once the newest version was pushed up everything worked fine.

As I mentioned on IRC it's always a good idea to exercise API changes via launchpadlib. Here's how I verified your new property:

1: lp = launchpad
2: u = lp.distributions['ubuntu']
3: hoary = u.getSeries(name_or_version='hoary')
4: ev = hoary.getSourcePackage(name='evolution')
5: dir(ev)
6: ev.latest_published_component_name

review: Approve (code)
Revision history for this message
Brad Crittenden (bac) wrote :

Adi I will be glad to land your branch when PQM re-opens after the roll out. Please remind me if I forget.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/interfaces/sourcepackage.py'
2--- lib/lp/registry/interfaces/sourcepackage.py 2010-02-10 07:36:25 +0000
3+++ lib/lp/registry/interfaces/sourcepackage.py 2010-03-02 18:29:15 +0000
4@@ -225,6 +225,11 @@
5 title=u'The component in which the package was last published.',
6 schema=IComponent, readonly=True, required=False)
7
8+ latest_published_component_name = exported(TextLine(
9+ title=u'The name of the component in which the package'
10+ ' was last published.',
11+ readonly=True, required=False))
12+
13 def get_default_archive(component=None):
14 """Get the default archive of this package.
15
16
17=== modified file 'lib/lp/registry/model/sourcepackage.py'
18--- lib/lp/registry/model/sourcepackage.py 2010-02-24 13:49:17 +0000
19+++ lib/lp/registry/model/sourcepackage.py 2010-03-02 18:29:15 +0000
20@@ -12,10 +12,10 @@
21 ]
22
23 from operator import attrgetter
24-from sqlobject.sqlbuilder import SQLConstant
25 from zope.interface import classProvides, implements
26 from zope.component import getUtility
27
28+from sqlobject.sqlbuilder import SQLConstant
29 from storm.locals import And, Desc, In, Select, SQL, Store
30
31 from canonical.database.constants import UTC_NOW
32@@ -566,6 +566,14 @@
33 else:
34 return None
35
36+ @property
37+ def latest_published_component_name(self):
38+ """See `ISourcePackage`."""
39+ if self.latest_published_component is not None:
40+ return self.latest_published_component.name
41+ else:
42+ return None
43+
44 def get_default_archive(self, component=None):
45 """See `ISourcePackage`."""
46 if component is None:
47
48=== modified file 'lib/lp/registry/stories/webservice/xx-source-package.txt'
49--- lib/lp/registry/stories/webservice/xx-source-package.txt 2009-12-24 01:41:54 +0000
50+++ lib/lp/registry/stories/webservice/xx-source-package.txt 2010-03-02 18:29:15 +0000
51@@ -1,4 +1,9 @@
52-= Prelude =
53+Source Package API
54+==================
55+
56+
57+Prelude
58+-------
59
60 >>> from zope.component import getUtility
61 >>> from lp.registry.interfaces.distribution import (
62@@ -11,7 +16,9 @@
63 >>> from canonical.launchpad.webapp.interfaces import OAuthPermission
64 >>> from lazr.restful.testing.webservice import pprint_entry
65
66-= Source Packages =
67+
68+Getting source packages
69+-----------------------
70
71 We can get source packages that are bound to a distribution series from the
72 distribution series.
73@@ -26,6 +33,7 @@
74 displayname: u'evolution in Ubuntu Hoary'
75 distribution_link: u'http://.../ubuntu'
76 distroseries_link: u'http://.../ubuntu/hoary'
77+ latest_published_component_name: u'main'
78 name: u'evolution'
79 official_bug_tags: []
80 productseries_link: u'http://.../evolution/trunk'
81@@ -33,7 +41,8 @@
82 self_link: u'http://.../ubuntu/hoary/+source/evolution'
83
84
85-== Getting official branches ==
86+Getting official branches
87+-------------------------
88
89 Then we can get the branches that are bound to various pockets of this
90 distribution series. By default, there are none bound to evolution.
91@@ -44,7 +53,8 @@
92 None
93
94
95-== Setting official branches ==
96+Setting official branches
97+-------------------------
98
99 We can even set a branch for the series. First we need to *make* a branch
100 though.