Merge ~cjwatson/launchpad:stormify-binarypackagename into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: d8798d341e219a4adb472640856fa4241ad12075
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:stormify-binarypackagename
Merge into: launchpad:master
Diff against target: 382 lines (+109/-50)
10 files modified
lib/lp/archiveuploader/tests/test_uploadprocessor.py (+5/-1)
lib/lp/registry/model/distribution.py (+5/-1)
lib/lp/registry/model/distroseries.py (+6/-3)
lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst (+16/-10)
lib/lp/soyuz/doc/distroseriesbinarypackage.rst (+6/-3)
lib/lp/soyuz/doc/gina-multiple-arch.rst (+15/-3)
lib/lp/soyuz/doc/gina.rst (+21/-5)
lib/lp/soyuz/model/binarypackagename.py (+23/-17)
lib/lp/soyuz/model/distroarchseries.py (+6/-4)
lib/lp/soyuz/scripts/gina/handlers.py (+6/-3)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+449655@code.launchpad.net

Commit message

Convert BinaryPackageName to Storm

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archiveuploader/tests/test_uploadprocessor.py b/lib/lp/archiveuploader/tests/test_uploadprocessor.py
2index 665bc0b..861dbe3 100644
3--- a/lib/lp/archiveuploader/tests/test_uploadprocessor.py
4+++ b/lib/lp/archiveuploader/tests/test_uploadprocessor.py
5@@ -1160,7 +1160,11 @@ class TestUploadProcessor(StatsMixin, TestUploadProcessorBase):
6 self.processUpload(uploadprocessor, upload_dir)
7
8 # Find the binarypackagerelease and check its component.
9- foocomm_binname = BinaryPackageName.selectOneBy(name="foocomm")
10+ foocomm_binname = (
11+ IStore(BinaryPackageName)
12+ .find(BinaryPackageName, name="foocomm")
13+ .one()
14+ )
15 foocomm_bpr = (
16 IStore(BinaryPackageRelease)
17 .find(BinaryPackageRelease, binarypackagename=foocomm_binname)
18diff --git a/lib/lp/registry/model/distribution.py b/lib/lp/registry/model/distribution.py
19index 6e245b7..a38cb03 100644
20--- a/lib/lp/registry/model/distribution.py
21+++ b/lib/lp/registry/model/distribution.py
22@@ -1790,7 +1790,11 @@ class Distribution(
23 # At this point we don't have a published source package by
24 # that name, so let's try to find a binary package and work
25 # back from there.
26- binarypackagename = BinaryPackageName.selectOneBy(name=pkgname)
27+ binarypackagename = (
28+ IStore(BinaryPackageName)
29+ .find(BinaryPackageName, name=pkgname)
30+ .one()
31+ )
32 if binarypackagename:
33 # Ok, so we have a binarypackage with that name. Grab its
34 # latest publication in the distribution (this may be an old
35diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py
36index cd596f2..d34d571 100644
37--- a/lib/lp/registry/model/distroseries.py
38+++ b/lib/lp/registry/model/distroseries.py
39@@ -1052,9 +1052,12 @@ class DistroSeries(
40 def getBinaryPackage(self, name):
41 """See `IDistroSeries`."""
42 if not IBinaryPackageName.providedBy(name):
43- try:
44- name = BinaryPackageName.byName(name)
45- except SQLObjectNotFound:
46+ name = (
47+ IStore(BinaryPackageName)
48+ .find(BinaryPackageName, name=name)
49+ .one()
50+ )
51+ if name is None:
52 return None
53 return DistroSeriesBinaryPackage(self, name)
54
55diff --git a/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst b/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst
56index 2b51ad9..90fd4b1 100644
57--- a/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst
58+++ b/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst
59@@ -2,14 +2,23 @@
60 Distro Arch Series Binary Package
61 =================================
62
63+ >>> from lp.services.database.interfaces import IStore
64 >>> from lp.soyuz.model.binarypackagename import BinaryPackageName
65 >>> from lp.soyuz.model.distroarchseries import DistroArchSeries
66 >>> from lp.soyuz.model.distroarchseriesbinarypackage import (
67 ... DistroArchSeriesBinaryPackage,
68 ... )
69 >>> hoary_i386 = DistroArchSeries.get(6)
70- >>> pmount_name = BinaryPackageName.selectOneBy(name="pmount")
71- >>> firefox_name = BinaryPackageName.selectOneBy(name="mozilla-firefox")
72+ >>> pmount_name = (
73+ ... IStore(BinaryPackageName)
74+ ... .find(BinaryPackageName, name="pmount")
75+ ... .one()
76+ ... )
77+ >>> firefox_name = (
78+ ... IStore(BinaryPackageName)
79+ ... .find(BinaryPackageName, name="mozilla-firefox")
80+ ... .one()
81+ ... )
82 >>> pmount_hoary_i386 = DistroArchSeriesBinaryPackage(
83 ... hoary_i386, pmount_name
84 ... )
85@@ -28,7 +37,6 @@ builds that are in sampledata!
86
87 >>> from lp.soyuz.model.publishing import BinaryPackagePublishingHistory
88 >>> from lp.services.database.constants import UTC_NOW
89- >>> from lp.services.database.interfaces import IStore
90 >>> from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
91 >>> from lp.soyuz.model.component import Component
92 >>> from lp.soyuz.model.section import Section
93@@ -263,14 +271,12 @@ Then, supersede all pmount publications in warty for pmount (this sets
94 us up to demonstrate bug 208233).
95
96 >>> switch_dbuser("archivepublisher")
97- >>> from lp.soyuz.model.binarypackagename import BinaryPackageName
98- >>> from lp.soyuz.model.distroarchseries import DistroArchSeries
99- >>> from lp.soyuz.model.distroarchseriesbinarypackage import (
100- ... DistroArchSeriesBinaryPackage,
101- ... )
102- >>> from lp.soyuz.model.publishing import BinaryPackagePublishingHistory
103 >>> warty_i386 = DistroArchSeries.get(1)
104- >>> pmount_name = BinaryPackageName.selectOneBy(name="pmount")
105+ >>> pmount_name = (
106+ ... IStore(BinaryPackageName)
107+ ... .find(BinaryPackageName, name="pmount")
108+ ... .one()
109+ ... )
110 >>> pmount_warty_i386 = DistroArchSeriesBinaryPackage(
111 ... warty_i386, pmount_name
112 ... )
113diff --git a/lib/lp/soyuz/doc/distroseriesbinarypackage.rst b/lib/lp/soyuz/doc/distroseriesbinarypackage.rst
114index a7386f6..011cf86 100644
115--- a/lib/lp/soyuz/doc/distroseriesbinarypackage.rst
116+++ b/lib/lp/soyuz/doc/distroseriesbinarypackage.rst
117@@ -8,15 +8,18 @@ releases and/or architectures for a given binary package name within a
118 specific distribution series.
119
120 >>> from zope.component import getUtility
121- >>> from lp.soyuz.model.binarypackagename import BinaryPackageName
122 >>> from lp.registry.interfaces.distribution import IDistributionSet
123+ >>> from lp.services.database.interfaces import IStore
124+ >>> from lp.soyuz.model.binarypackagename import BinaryPackageName
125
126 A DistroSeriesBinaryPackage is normally accessed via a Distro
127 Series:
128
129 >>> ubuntu = getUtility(IDistributionSet)["ubuntu"]
130- >>> firefox_bin_name = BinaryPackageName.selectOneBy(
131- ... name="mozilla-firefox"
132+ >>> firefox_bin_name = (
133+ ... IStore(BinaryPackageName)
134+ ... .find(BinaryPackageName, name="mozilla-firefox")
135+ ... .one()
136 ... )
137 >>> firefox_dsbp = ubuntu["warty"].getBinaryPackage(firefox_bin_name)
138
139diff --git a/lib/lp/soyuz/doc/gina-multiple-arch.rst b/lib/lp/soyuz/doc/gina-multiple-arch.rst
140index 495b8eb..e2d84b1 100644
141--- a/lib/lp/soyuz/doc/gina-multiple-arch.rst
142+++ b/lib/lp/soyuz/doc/gina-multiple-arch.rst
143@@ -182,7 +182,11 @@ Check that the source package was correctly imported:
144
145 And that one of the packages in main is here too:
146
147- >>> n = BinaryPackageName.selectOneBy(name="libgadu-dev")
148+ >>> n = (
149+ ... IStore(BinaryPackageName)
150+ ... .find(BinaryPackageName, name="libgadu-dev")
151+ ... .one()
152+ ... )
153 >>> ekg = (
154 ... IStore(BinaryPackageRelease)
155 ... .find(
156@@ -206,7 +210,11 @@ processed. In particular, its section should be stripped of the
157 component name.
158
159 >>> from lp.soyuz.enums import PackagePublishingPriority
160- >>> n = BinaryPackageName.selectOneBy(name="ekg")
161+ >>> n = (
162+ ... IStore(BinaryPackageName)
163+ ... .find(BinaryPackageName, name="ekg")
164+ ... .one()
165+ ... )
166 >>> ekg = (
167 ... IStore(BinaryPackageRelease)
168 ... .find(
169@@ -229,7 +237,11 @@ package files are in main! Gina to the rescue: it finds them in the
170 right place, updates the component, and creates it with a semi-bogus
171 DSC.
172
173- >>> n = BinaryPackageName.selectOneBy(name="bdftopcf")
174+ >>> n = (
175+ ... IStore(BinaryPackageName)
176+ ... .find(BinaryPackageName, name="bdftopcf")
177+ ... .one()
178+ ... )
179 >>> ekg = (
180 ... IStore(BinaryPackageRelease)
181 ... .find(
182diff --git a/lib/lp/soyuz/doc/gina.rst b/lib/lp/soyuz/doc/gina.rst
183index 39bcbdb..a934313 100644
184--- a/lib/lp/soyuz/doc/gina.rst
185+++ b/lib/lp/soyuz/doc/gina.rst
186@@ -445,7 +445,11 @@ Check that the shlibs parsing and bin-only-NMU version handling works as
187 expected:
188
189 >>> from lp.soyuz.model.binarypackagename import BinaryPackageName
190- >>> n = BinaryPackageName.selectOneBy(name="rioutil")
191+ >>> n = (
192+ ... IStore(BinaryPackageName)
193+ ... .find(BinaryPackageName, name="rioutil")
194+ ... .one()
195+ ... )
196 >>> rio = (
197 ... IStore(BinaryPackageRelease)
198 ... .find(BinaryPackageRelease, binarypackagename=n)
199@@ -461,7 +465,7 @@ expected:
200 Test all the data got to the ed BPR intact, and that the missing
201 priority was correctly munged to "extra":
202
203- >>> n = BinaryPackageName.selectOneBy(name="ed")
204+ >>> n = IStore(BinaryPackageName).find(BinaryPackageName, name="ed").one()
205 >>> ed = (
206 ... IStore(BinaryPackageRelease)
207 ... .find(BinaryPackageRelease, binarypackagename=n)
208@@ -499,7 +503,11 @@ We now check if the Breezy publication record has the correct priority:
209 Check binary package libgjc-dev in Breezy. Its version number must differ from
210 its source version number.
211
212- >>> n = BinaryPackageName.selectOneBy(name="libgcj-dev")
213+ >>> n = (
214+ ... IStore(BinaryPackageName)
215+ ... .find(BinaryPackageName, name="libgcj-dev")
216+ ... .one()
217+ ... )
218 >>> lib = (
219 ... IStore(BinaryPackageRelease)
220 ... .find(
221@@ -516,7 +524,11 @@ its source version number.
222
223 Check if the udeb was properly parsed and identified:
224
225- >>> n = BinaryPackageName.selectOneBy(name="archive-copier")
226+ >>> n = (
227+ ... IStore(BinaryPackageName)
228+ ... .find(BinaryPackageName, name="archive-copier")
229+ ... .one()
230+ ... )
231 >>> ac = (
232 ... IStore(BinaryPackageRelease)
233 ... .find(BinaryPackageRelease, binarypackagename=n, version="0.1.5")
234@@ -537,7 +549,11 @@ Check if the udeb was properly parsed and identified:
235
236 We check that the binary package publishing override facility works:
237
238- >>> n = BinaryPackageName.selectOneBy(name="libdb1-compat")
239+ >>> n = (
240+ ... IStore(BinaryPackageName)
241+ ... .find(BinaryPackageName, name="libdb1-compat")
242+ ... .one()
243+ ... )
244 >>> db1 = (
245 ... IStore(BinaryPackageRelease)
246 ... .find(
247diff --git a/lib/lp/soyuz/model/binarypackagename.py b/lib/lp/soyuz/model/binarypackagename.py
248index a60dbab..bb55043 100644
249--- a/lib/lp/soyuz/model/binarypackagename.py
250+++ b/lib/lp/soyuz/model/binarypackagename.py
251@@ -6,15 +6,14 @@ __all__ = [
252 "BinaryPackageNameSet",
253 ]
254
255-import six
256 from storm.expr import Join
257+from storm.properties import Int, Unicode
258 from storm.store import EmptyResultSet
259 from zope.interface import implementer
260
261 from lp.app.errors import NotFoundError
262 from lp.services.database.interfaces import IStore
263-from lp.services.database.sqlbase import SQLBase
264-from lp.services.database.sqlobject import SQLObjectNotFound, StringCol
265+from lp.services.database.stormbase import StormBase
266 from lp.soyuz.interfaces.binarypackagename import (
267 IBinaryPackageName,
268 IBinaryPackageNameSet,
269@@ -23,11 +22,15 @@ from lp.soyuz.interfaces.publishing import active_publishing_status
270
271
272 @implementer(IBinaryPackageName)
273-class BinaryPackageName(SQLBase):
274- _table = "BinaryPackageName"
275- name = StringCol(
276- dbName="name", notNull=True, unique=True, alternateID=True
277- )
278+class BinaryPackageName(StormBase):
279+ __storm_table__ = "BinaryPackageName"
280+
281+ id = Int(primary=True)
282+ name = Unicode(name="name", allow_none=False)
283+
284+ def __init__(self, name):
285+ super().__init__()
286+ self.name = name
287
288 def __str__(self):
289 return self.name
290@@ -40,24 +43,28 @@ class BinaryPackageName(SQLBase):
291 class BinaryPackageNameSet:
292 def __getitem__(self, name):
293 """See `IBinaryPackageNameSet`."""
294- try:
295- return BinaryPackageName.byName(name)
296- except SQLObjectNotFound:
297+ bpn = (
298+ IStore(BinaryPackageName).find(BinaryPackageName, name=name).one()
299+ )
300+ if bpn is None:
301 raise NotFoundError(name)
302+ return bpn
303
304 def getAll(self):
305 """See `IBinaryPackageNameSet`."""
306- return BinaryPackageName.select()
307+ return IStore(BinaryPackageName).find(BinaryPackageName)
308
309 def queryByName(self, name):
310 return (
311- IStore(BinaryPackageName)
312- .find(BinaryPackageName, name=six.ensure_text(name, "ASCII"))
313- .one()
314+ IStore(BinaryPackageName).find(BinaryPackageName, name=name).one()
315 )
316
317 def new(self, name):
318- return BinaryPackageName(name=six.ensure_text(name, "ASCII"))
319+ bpn = BinaryPackageName(name=name)
320+ store = IStore(BinaryPackageName)
321+ store.add(bpn)
322+ store.flush()
323+ return bpn
324
325 def ensure(self, name):
326 """Ensure that the given BinaryPackageName exists, creating it
327@@ -65,7 +72,6 @@ class BinaryPackageNameSet:
328
329 Returns the BinaryPackageName
330 """
331- name = six.ensure_text(name, "ASCII")
332 try:
333 return self[name]
334 except NotFoundError:
335diff --git a/lib/lp/soyuz/model/distroarchseries.py b/lib/lp/soyuz/model/distroarchseries.py
336index 15bd5ef..cb9b669 100644
337--- a/lib/lp/soyuz/model/distroarchseries.py
338+++ b/lib/lp/soyuz/model/distroarchseries.py
339@@ -24,7 +24,6 @@ from lp.services.database.sqlobject import (
340 BoolCol,
341 ForeignKey,
342 IntCol,
343- SQLObjectNotFound,
344 StringCol,
345 )
346 from lp.services.database.stormexpr import fti_search, rank_by_fti
347@@ -348,9 +347,12 @@ class DistroArchSeries(SQLBase):
348 )
349
350 if not IBinaryPackageName.providedBy(name):
351- try:
352- name = BinaryPackageName.byName(name)
353- except SQLObjectNotFound:
354+ name = (
355+ IStore(BinaryPackageName)
356+ .find(BinaryPackageName, name=name)
357+ .one()
358+ )
359+ if name is None:
360 return None
361 return DistroArchSeriesBinaryPackage(self, name)
362
363diff --git a/lib/lp/soyuz/scripts/gina/handlers.py b/lib/lp/soyuz/scripts/gina/handlers.py
364index 67368b9..ae2d08c 100644
365--- a/lib/lp/soyuz/scripts/gina/handlers.py
366+++ b/lib/lp/soyuz/scripts/gina/handlers.py
367@@ -805,9 +805,12 @@ class BinaryPackageHandler:
368
369 def checkBin(self, binarypackagedata, distroarchseries):
370 """Returns a binarypackage -- if it exists."""
371- try:
372- binaryname = BinaryPackageName.byName(binarypackagedata.package)
373- except SQLObjectNotFound:
374+ binaryname = (
375+ IStore(BinaryPackageName)
376+ .find(BinaryPackageName, name=binarypackagedata.package)
377+ .one()
378+ )
379+ if binaryname is None:
380 # If the binary package's name doesn't exist, don't even
381 # bother looking for a binary package.
382 return None

Subscribers

People subscribed via source and target branches

to status/vote changes: