Merge lp:~jelmer/launchpad/621778-homepage-field into lp:launchpad/db-devel

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 9719
Proposed branch: lp:~jelmer/launchpad/621778-homepage-field
Merge into: lp:launchpad/db-devel
Diff against target: 269 lines (+80/-10)
13 files modified
database/schema/comments.sql (+2/-0)
database/schema/patch-2208-05-0.sql (+11/-0)
lib/lp/registry/interfaces/distroseries.py (+4/-1)
lib/lp/registry/model/distroseries.py (+3/-2)
lib/lp/soyuz/interfaces/binarypackagebuild.py (+1/-1)
lib/lp/soyuz/interfaces/binarypackagerelease.py (+7/-0)
lib/lp/soyuz/interfaces/sourcepackagerelease.py (+8/-0)
lib/lp/soyuz/model/binarypackagebuild.py (+2/-2)
lib/lp/soyuz/model/binarypackagerelease.py (+1/-0)
lib/lp/soyuz/model/sourcepackagerelease.py (+1/-0)
lib/lp/soyuz/tests/test_binarypackagerelease.py (+16/-0)
lib/lp/soyuz/tests/test_sourcepackagerelease.py (+16/-0)
lib/lp/testing/factory.py (+8/-4)
To merge this branch: bzr merge lp:~jelmer/launchpad/621778-homepage-field
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Steve Kowalik (community) code* Approve
Stuart Bishop (community) db Approve
Robert Collins (community) db Approve
Review via email: mp+33331@code.launchpad.net

Commit message

Add SourcePackageRelease.homepage, BinaryPackageRelease.homepage.

Description of the change

This adds a "Homepage" field to SourcePackageRelease and BinaryPackageRelease.

This field was added to the Debian policy a fairly recently, see http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Homepage

I'm adding this field so that it can be used as the default value for the upstream homepage URL when creating an upstream project from an Ubuntu source package.

See: https://bugs.edge.launchpad.net/launchpad-registry/+bug/621778

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

If you're adding in python support for this, I think a couple of tests would be sensible: e.g. that you want it nullable.

DB side looks fine.

review: Approve (db)
Revision history for this message
Stuart Bishop (stub) wrote :

Is homepage one word or two? Both forms are in common use and I don't know if LP Style prefers homepage or home_page.

DB patch is fine. It would be lovely if we could enforce the format of the string using a CHECK constraint, but I don't think we can - we have to accept whatever rubbish the user put in the package that they uploaded. You might want to mention this in the comment before anyone attempts to naively mark it up (possible attack vector there if someone sticks Javascript in the homepage field and we don't validate the URL before marking it up).

patch-2208-05-0.sql

review: Approve (db)
Revision history for this message
Robert Collins (lifeless) wrote :

On Mon, Aug 23, 2010 at 6:25 PM, Stuart Bishop
<email address hidden> wrote:
> Review: Approve db
> Is homepage one word or two? Both forms are in common use and I don't know if LP Style prefers homepage or home_page.
>
> DB patch is fine. It would be lovely if we could enforce the format of the string using a CHECK constraint, but I don't think we can - we have to accept whatever rubbish the user put in the package that they uploaded. You might want to mention this in the comment before anyone attempts to naively mark it up (possible attack vector there if someone sticks Javascript in the homepage field and we don't validate the URL before marking it up).

Good catch: I suggest making the factory function return just such a
javascript function by default, to make it blindingly obvious :)

-Rob

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> Is homepage one word or two? Both forms are in common use and I don't know if
> LP Style prefers homepage or home_page.
Both "homepage" and "home page" are allowed according to my dictionary. "homepage" appears to be used more often in the Launchpad source code.

> DB patch is fine. It would be lovely if we could enforce the format of the
> string using a CHECK constraint, but I don't think we can - we have to accept
> whatever rubbish the user put in the package that they uploaded. You might
> want to mention this in the comment before anyone attempts to naively mark it
> up (possible attack vector there if someone sticks Javascript in the homepage
> field and we don't validate the URL before marking it up).
Makes sense, updated in the database comment and the API interface.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> > Is homepage one word or two? Both forms are in common use and I don't know
> if
> > LP Style prefers homepage or home_page.
> Both "homepage" and "home page" are allowed according to my dictionary.
> "homepage" appears to be used more often in the Launchpad source code.
"Homepage" is also the name of the field in the Debian control file from which this field will be set.

Revision history for this message
Steve Kowalik (stevenk) wrote :

Hi,

These changes look pretty good, I just have some concerns:

* There exists lp.services.fields.URIField that allows for validation of URIs that are passed to it. Does that sound like a better fit than TextField?
* Why is homepage not exported over the API?

review: Needs Information (code*)
Revision history for this message
Steve Kowalik (stevenk) wrote :

One thing I forgot to mention is the you aren't using the patch filename that stub mentioned.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> These changes look pretty good, I just have some concerns:
>
> * There exists lp.services.fields.URIField that allows for validation of URIs
> that are passed to it. Does that sound like a better fit than TextField?
Since we're importing the homepage field from the user-provided Debian package control fields, we can't rely on the homepage field containing a valid URL.

> * Why is homepage not exported over the API?
Mainly because the rest of SourcePackageRelease/BinaryPackageRelease isn't exported either, it seemed out of scope for this branch.

Revision history for this message
Steve Kowalik (stevenk) wrote :

Okay, this looks good to me!

review: Approve (code*)
Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/comments.sql'
2--- database/schema/comments.sql 2010-08-23 04:51:48 +0000
3+++ database/schema/comments.sql 2010-08-25 12:22:47 +0000
4@@ -1339,6 +1339,7 @@
5 COMMENT ON COLUMN SourcePackageRelease.build_conflicts_indep IS 'The list of packages that will conflict with this source while building in architecture independent environment, as mentioned in the control file "Build-Conflicts-Indep:" field.';
6 COMMENT ON COLUMN SourcePackageRelease.changelog IS 'The LibraryFileAlias ID of changelog associated with this sourcepackage. Often in the case of debian packages and will be found after the installation in /usr/share/doc/<binarypackagename>/changelog.Debian.gz';
7 COMMENT ON COLUMN SourcePackageRelease.user_defined_fields IS 'A JSON struct containing a sequence of key-value pairs with user defined fields in the control file.';
8+COMMENT ON COLUMN SourcePackageRelease.homepage IS 'Upstream project homepage URL, not checked for validity.';
9
10 -- SourcePackageName
11
12@@ -1480,6 +1481,7 @@
13 COMMENT ON COLUMN BinaryPackageRelease.breaks IS 'The list of packages which will be broken by the installtion of this package, as it is in the control file "Breaks:" field.';
14 COMMENT ON COLUMN BinaryPackageRelease.debug_package IS 'The corresponding binary package release containing debug symbols for this binary, if any.';
15 COMMENT ON COLUMN BinaryPackageRelease.user_defined_fields IS 'A JSON struct containing a sequence of key-value pairs with user defined fields in the control file.';
16+COMMENT ON COLUMN BinaryPackageRelease.homepage IS 'Upstream project homepage URL, not checked for validity.';
17
18
19 -- BinaryPackageFile
20
21=== added file 'database/schema/patch-2208-05-0.sql'
22--- database/schema/patch-2208-05-0.sql 1970-01-01 00:00:00 +0000
23+++ database/schema/patch-2208-05-0.sql 2010-08-25 12:22:47 +0000
24@@ -0,0 +1,11 @@
25+-- Copyright 2010 Canonical Ltd. This software is licensed under the
26+-- GNU Affero General Public License version 3 (see the file LICENSE).
27+SET client_min_messages=ERROR;
28+
29+ALTER TABLE BinaryPackageRelease
30+ ADD COLUMN homepage TEXT;
31+
32+ALTER TABLE SourcePackageRelease
33+ ADD COLUMN homepage TEXT;
34+
35+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 05, 0);
36
37=== modified file 'lib/lp/registry/interfaces/distroseries.py'
38--- lib/lp/registry/interfaces/distroseries.py 2010-08-21 13:54:20 +0000
39+++ lib/lp/registry/interfaces/distroseries.py 2010-08-25 12:22:47 +0000
40@@ -602,7 +602,8 @@
41 dsc_maintainer_rfc822, dsc_standards_version, dsc_format,
42 dsc_binaries, archive, copyright, build_conflicts,
43 build_conflicts_indep, dateuploaded=None,
44- source_package_recipe_build=None, user_defined_fields=None):
45+ source_package_recipe_build=None, user_defined_fields=None,
46+ homepage=None):
47 """Create an uploads `SourcePackageRelease`.
48
49 Set this distroseries set to be the uploadeddistroseries.
50@@ -640,6 +641,8 @@
51 :param source_package_recipe_build: optional SourcePackageRecipeBuild
52 :param user_defined_fields: optional sequence of key-value pairs with
53 user defined fields.
54+ :param homepage: optional string with (unchecked) upstream homepage
55+ URL
56 :return: the just creates `SourcePackageRelease`
57 """
58
59
60=== modified file 'lib/lp/registry/model/distroseries.py'
61--- lib/lp/registry/model/distroseries.py 2010-08-24 20:30:48 +0000
62+++ lib/lp/registry/model/distroseries.py 2010-08-25 12:22:47 +0000
63@@ -1186,7 +1186,8 @@
64 dsc_maintainer_rfc822, dsc_standards_version, dsc_format,
65 dsc_binaries, archive, copyright, build_conflicts,
66 build_conflicts_indep, dateuploaded=DEFAULT,
67- source_package_recipe_build=None, user_defined_fields=None):
68+ source_package_recipe_build=None, user_defined_fields=None,
69+ homepage=None):
70 """See `IDistroSeries`."""
71 return SourcePackageRelease(
72 upload_distroseries=self, sourcepackagename=sourcepackagename,
73@@ -1203,7 +1204,7 @@
74 build_conflicts=build_conflicts,
75 build_conflicts_indep=build_conflicts_indep,
76 source_package_recipe_build=source_package_recipe_build,
77- user_defined_fields=user_defined_fields)
78+ user_defined_fields=user_defined_fields, homepage=homepage)
79
80 def getComponentByName(self, name):
81 """See `IDistroSeries`."""
82
83=== modified file 'lib/lp/soyuz/interfaces/binarypackagebuild.py'
84--- lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-21 13:54:20 +0000
85+++ lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-25 12:22:47 +0000
86@@ -140,7 +140,7 @@
87 shlibdeps=None, depends=None, recommends=None, suggests=None,
88 conflicts=None, replaces=None, provides=None, pre_depends=None,
89 enhances=None, breaks=None, essential=False, debug_package=None,
90- user_defined_fields=None):
91+ user_defined_fields=None, homepage=None):
92 """Create and return a `BinaryPackageRelease`.
93
94 The binarypackagerelease will be attached to this specific build.
95
96=== modified file 'lib/lp/soyuz/interfaces/binarypackagerelease.py'
97--- lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-08-21 13:56:34 +0000
98+++ lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-08-25 12:22:47 +0000
99@@ -80,6 +80,13 @@
100 user_defined_fields = List(
101 title=_("Sequence of user-defined fields as key-value pairs."))
102
103+ homepage = TextLine(
104+ title=_("Homepage"),
105+ description=_(
106+ "Upstream project homepage as set in the package. This URL is not "
107+ "sanitized."),
108+ required=False)
109+
110 files = Attribute("Related list of IBinaryPackageFile entries")
111
112 title = TextLine(required=True, readonly=True)
113
114=== modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py'
115--- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-08-21 13:56:34 +0000
116+++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-08-25 12:22:47 +0000
117@@ -104,6 +104,14 @@
118
119 user_defined_fields = List(
120 title=_("Sequence of user-defined fields as key-value pairs."))
121+
122+ homepage = TextLine(
123+ title=_("Homepage"),
124+ description=_(
125+ "Upstream project homepage as set in the package. This URL is not "
126+ "sanitized."),
127+ required=False)
128+
129 # read-only properties
130 name = Attribute('The sourcepackagename for this release, as text')
131 title = Attribute('The title of this sourcepackagerelease')
132
133=== modified file 'lib/lp/soyuz/model/binarypackagebuild.py'
134--- lib/lp/soyuz/model/binarypackagebuild.py 2010-08-25 00:30:21 +0000
135+++ lib/lp/soyuz/model/binarypackagebuild.py 2010-08-25 12:22:47 +0000
136@@ -485,7 +485,7 @@
137 architecturespecific, shlibdeps=None, depends=None, recommends=None,
138 suggests=None, conflicts=None, replaces=None, provides=None,
139 pre_depends=None, enhances=None, breaks=None, essential=False,
140- debug_package=None, user_defined_fields=None):
141+ debug_package=None, user_defined_fields=None, homepage=None):
142 """See IBuild."""
143 return BinaryPackageRelease(
144 build=self, binarypackagename=binarypackagename, version=version,
145@@ -498,7 +498,7 @@
146 breaks=breaks, essential=essential, installedsize=installedsize,
147 architecturespecific=architecturespecific,
148 debug_package=debug_package,
149- user_defined_fields=user_defined_fields)
150+ user_defined_fields=user_defined_fields, homepage=homepage)
151
152 def estimateDuration(self):
153 """See `IPackageBuild`."""
154
155=== modified file 'lib/lp/soyuz/model/binarypackagerelease.py'
156--- lib/lp/soyuz/model/binarypackagerelease.py 2010-08-21 13:56:34 +0000
157+++ lib/lp/soyuz/model/binarypackagerelease.py 2010-08-25 12:22:47 +0000
158@@ -81,6 +81,7 @@
159 installedsize = IntCol(dbName='installedsize')
160 architecturespecific = BoolCol(dbName='architecturespecific',
161 notNull=True)
162+ homepage = StringCol(dbName='homepage')
163 datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW)
164 debug_package = ForeignKey(dbName='debug_package',
165 foreignKey='BinaryPackageRelease')
166
167=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
168--- lib/lp/soyuz/model/sourcepackagerelease.py 2010-08-21 13:56:34 +0000
169+++ lib/lp/soyuz/model/sourcepackagerelease.py 2010-08-25 12:22:47 +0000
170@@ -146,6 +146,7 @@
171 build_conflicts = StringCol(dbName='build_conflicts')
172 build_conflicts_indep = StringCol(dbName='build_conflicts_indep')
173 architecturehintlist = StringCol(dbName='architecturehintlist')
174+ homepage = StringCol(dbName='homepage')
175 format = EnumCol(dbName='format', schema=SourcePackageType,
176 default=SourcePackageType.DPKG, notNull=True)
177 upload_distroseries = ForeignKey(foreignKey='DistroSeries',
178
179=== modified file 'lib/lp/soyuz/tests/test_binarypackagerelease.py'
180--- lib/lp/soyuz/tests/test_binarypackagerelease.py 2010-08-21 13:56:34 +0000
181+++ lib/lp/soyuz/tests/test_binarypackagerelease.py 2010-08-25 12:22:47 +0000
182@@ -49,3 +49,19 @@
183 self.assertEquals([
184 ["Python-Version", ">= 2.4"],
185 ["Other", "Bla"]], release.user_defined_fields)
186+
187+ def test_homepage_default(self):
188+ # By default, no homepage is set.
189+ bpr = self.factory.makeBinaryPackageRelease()
190+ self.assertEquals(None, bpr.homepage)
191+
192+ def test_homepage_empty(self):
193+ # The homepage field can be empty.
194+ bpr = self.factory.makeBinaryPackageRelease(homepage="")
195+ self.assertEquals("", bpr.homepage)
196+
197+ def test_homepage_set_invalid(self):
198+ # As the homepage field is inherited from the .deb, the URL
199+ # does not have to be valid.
200+ bpr = self.factory.makeBinaryPackageRelease(homepage="<invalid<url")
201+ self.assertEquals("<invalid<url", bpr.homepage)
202
203=== modified file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
204--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-08-21 13:54:20 +0000
205+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-08-25 12:22:47 +0000
206@@ -38,3 +38,19 @@
207 self.assertEquals([
208 ["Python-Version", ">= 2.4"],
209 ["Other", "Bla"]], release.user_defined_fields)
210+
211+ def test_homepage_default(self):
212+ # By default, no homepage is set.
213+ spr = self.factory.makeSourcePackageRelease()
214+ self.assertEquals(None, spr.homepage)
215+
216+ def test_homepage_empty(self):
217+ # The homepage field can be empty.
218+ spr = self.factory.makeSourcePackageRelease(homepage="")
219+ self.assertEquals("", spr.homepage)
220+
221+ def test_homepage_set_invalid(self):
222+ # As the homepage field is inherited from the DSCFile, the URL
223+ # does not have to be valid.
224+ spr = self.factory.makeSourcePackageRelease(homepage="<invalid<url")
225+ self.assertEquals("<invalid<url", spr.homepage)
226
227=== modified file 'lib/lp/testing/factory.py'
228--- lib/lp/testing/factory.py 2010-08-23 08:12:39 +0000
229+++ lib/lp/testing/factory.py 2010-08-25 12:22:47 +0000
230@@ -2408,7 +2408,8 @@
231 date_uploaded=UTC_NOW,
232 source_package_recipe_build=None,
233 dscsigningkey=None,
234- user_defined_fields=None):
235+ user_defined_fields=None,
236+ homepage=None):
237 """Make a `SourcePackageRelease`."""
238 if distroseries is None:
239 if source_package_recipe_build is not None:
240@@ -2476,7 +2477,8 @@
241 archive=archive,
242 dateuploaded=date_uploaded,
243 source_package_recipe_build=source_package_recipe_build,
244- user_defined_fields=user_defined_fields)
245+ user_defined_fields=user_defined_fields,
246+ homepage=homepage)
247
248 def makeSourcePackageReleaseFile(self, sourcepackagerelease=None,
249 library_file=None, filetype=None):
250@@ -2704,7 +2706,8 @@
251 provides=None, pre_depends=None,
252 enhances=None, breaks=None,
253 essential=False, installed_size=None,
254- date_created=None, debug_package=None):
255+ date_created=None, debug_package=None,
256+ homepage=None):
257 """Make a `BinaryPackageRelease`."""
258 if build is None:
259 build = self.makeBinaryPackageBuild()
260@@ -2735,7 +2738,8 @@
261 suggests=suggests, conflicts=conflicts, replaces=replaces,
262 provides=provides, pre_depends=pre_depends,
263 enhances=enhances, breaks=breaks, essential=essential,
264- installedsize=installed_size, debug_package=debug_package)
265+ installedsize=installed_size, debug_package=debug_package,
266+ homepage=homepage)
267 if date_created is not None:
268 removeSecurityProxy(bpr).datecreated = date_created
269 return bpr

Subscribers

People subscribed via source and target branches

to status/vote changes: