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
=== modified file 'lib/lp/registry/interfaces/sourcepackage.py'
--- lib/lp/registry/interfaces/sourcepackage.py 2010-02-10 07:36:25 +0000
+++ lib/lp/registry/interfaces/sourcepackage.py 2010-03-02 18:29:15 +0000
@@ -225,6 +225,11 @@
225 title=u'The component in which the package was last published.',225 title=u'The component in which the package was last published.',
226 schema=IComponent, readonly=True, required=False)226 schema=IComponent, readonly=True, required=False)
227227
228 latest_published_component_name = exported(TextLine(
229 title=u'The name of the component in which the package'
230 ' was last published.',
231 readonly=True, required=False))
232
228 def get_default_archive(component=None):233 def get_default_archive(component=None):
229 """Get the default archive of this package.234 """Get the default archive of this package.
230235
231236
=== modified file 'lib/lp/registry/model/sourcepackage.py'
--- lib/lp/registry/model/sourcepackage.py 2010-02-24 13:49:17 +0000
+++ lib/lp/registry/model/sourcepackage.py 2010-03-02 18:29:15 +0000
@@ -12,10 +12,10 @@
12 ]12 ]
1313
14from operator import attrgetter14from operator import attrgetter
15from sqlobject.sqlbuilder import SQLConstant
16from zope.interface import classProvides, implements15from zope.interface import classProvides, implements
17from zope.component import getUtility16from zope.component import getUtility
1817
18from sqlobject.sqlbuilder import SQLConstant
19from storm.locals import And, Desc, In, Select, SQL, Store19from storm.locals import And, Desc, In, Select, SQL, Store
2020
21from canonical.database.constants import UTC_NOW21from canonical.database.constants import UTC_NOW
@@ -566,6 +566,14 @@
566 else:566 else:
567 return None567 return None
568568
569 @property
570 def latest_published_component_name(self):
571 """See `ISourcePackage`."""
572 if self.latest_published_component is not None:
573 return self.latest_published_component.name
574 else:
575 return None
576
569 def get_default_archive(self, component=None):577 def get_default_archive(self, component=None):
570 """See `ISourcePackage`."""578 """See `ISourcePackage`."""
571 if component is None:579 if component is None:
572580
=== modified file 'lib/lp/registry/stories/webservice/xx-source-package.txt'
--- lib/lp/registry/stories/webservice/xx-source-package.txt 2009-12-24 01:41:54 +0000
+++ lib/lp/registry/stories/webservice/xx-source-package.txt 2010-03-02 18:29:15 +0000
@@ -1,4 +1,9 @@
1= Prelude =1Source Package API
2==================
3
4
5Prelude
6-------
27
3 >>> from zope.component import getUtility8 >>> from zope.component import getUtility
4 >>> from lp.registry.interfaces.distribution import (9 >>> from lp.registry.interfaces.distribution import (
@@ -11,7 +16,9 @@
11 >>> from canonical.launchpad.webapp.interfaces import OAuthPermission16 >>> from canonical.launchpad.webapp.interfaces import OAuthPermission
12 >>> from lazr.restful.testing.webservice import pprint_entry17 >>> from lazr.restful.testing.webservice import pprint_entry
1318
14= Source Packages =19
20Getting source packages
21-----------------------
1522
16We can get source packages that are bound to a distribution series from the23We can get source packages that are bound to a distribution series from the
17distribution series.24distribution series.
@@ -26,6 +33,7 @@
26 displayname: u'evolution in Ubuntu Hoary'33 displayname: u'evolution in Ubuntu Hoary'
27 distribution_link: u'http://.../ubuntu'34 distribution_link: u'http://.../ubuntu'
28 distroseries_link: u'http://.../ubuntu/hoary'35 distroseries_link: u'http://.../ubuntu/hoary'
36 latest_published_component_name: u'main'
29 name: u'evolution'37 name: u'evolution'
30 official_bug_tags: []38 official_bug_tags: []
31 productseries_link: u'http://.../evolution/trunk'39 productseries_link: u'http://.../evolution/trunk'
@@ -33,7 +41,8 @@
33 self_link: u'http://.../ubuntu/hoary/+source/evolution'41 self_link: u'http://.../ubuntu/hoary/+source/evolution'
3442
3543
36== Getting official branches ==44Getting official branches
45-------------------------
3746
38Then we can get the branches that are bound to various pockets of this47Then we can get the branches that are bound to various pockets of this
39distribution series. By default, there are none bound to evolution.48distribution series. By default, there are none bound to evolution.
@@ -44,7 +53,8 @@
44 None53 None
4554
4655
47== Setting official branches ==56Setting official branches
57-------------------------
4858
49We can even set a branch for the series. First we need to *make* a branch59We can even set a branch for the series. First we need to *make* a branch
50though.60though.