Merge ~cjwatson/launchpad:stormify-package-files into launchpad:master
- Git
- lp:~cjwatson/launchpad
- stormify-package-files
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 919ae1629fe04722bf7c50c05830c2ec7df6b9c1 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:stormify-package-files |
Merge into: | launchpad:master |
Diff against target: |
638 lines (+118/-87) 18 files modified
lib/lp/archivepublisher/artifactory.py (+2/-2) lib/lp/archivepublisher/deathrow.py (+2/-2) lib/lp/archivepublisher/model/ftparchive.py (+4/-4) lib/lp/registry/doc/distribution-mirror.rst (+7/-2) lib/lp/registry/model/distributionmirror.py (+1/-1) lib/lp/services/librarian/model.py (+11/-11) lib/lp/soyuz/browser/queue.py (+3/-3) lib/lp/soyuz/doc/build-files.rst (+1/-1) lib/lp/soyuz/doc/gina.rst (+4/-2) lib/lp/soyuz/interfaces/files.py (+3/-3) lib/lp/soyuz/model/archive.py (+16/-16) lib/lp/soyuz/model/binarypackagebuild.py (+4/-4) lib/lp/soyuz/model/files.py (+39/-17) lib/lp/soyuz/model/packagediff.py (+2/-2) lib/lp/soyuz/model/publishing.py (+15/-13) lib/lp/soyuz/model/sourcepackagerelease.py (+2/-2) lib/lp/soyuz/scripts/expire_archive_files.py (+1/-1) lib/lp/soyuz/scripts/gina/handlers.py (+1/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guruprasad | Approve | ||
Review via email: mp+436063@code.launchpad.net |
Commit message
Convert SourcePackageRe
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/archivepublisher/artifactory.py b/lib/lp/archivepublisher/artifactory.py |
2 | index 5e81ee6..041e73e 100644 |
3 | --- a/lib/lp/archivepublisher/artifactory.py |
4 | +++ b/lib/lp/archivepublisher/artifactory.py |
5 | @@ -142,11 +142,11 @@ class ArtifactoryPoolEntry: |
6 | """ |
7 | if ISourcePackageReleaseFile.providedBy(pub_file): |
8 | return "source:{:d}".format( |
9 | - pub_file.sourcepackagereleaseID |
10 | + pub_file.sourcepackagerelease_id |
11 | ) # type: ignore |
12 | elif IBinaryPackageFile.providedBy(pub_file): |
13 | return "binary:{:d}".format( |
14 | - pub_file.binarypackagereleaseID |
15 | + pub_file.binarypackagerelease_id |
16 | ) # type: ignore |
17 | else: |
18 | raise AssertionError("Unsupported file: %r" % pub_file) |
19 | diff --git a/lib/lp/archivepublisher/deathrow.py b/lib/lp/archivepublisher/deathrow.py |
20 | index 2d885e9..80f463e 100644 |
21 | --- a/lib/lp/archivepublisher/deathrow.py |
22 | +++ b/lib/lp/archivepublisher/deathrow.py |
23 | @@ -178,7 +178,7 @@ class DeathRow: |
24 | SourcePackagePublishingHistory.archive == self.archive, |
25 | SourcePackagePublishingHistory.dateremoved == None, |
26 | SourcePackagePublishingHistory.sourcepackagerelease |
27 | - == SourcePackageReleaseFile.sourcepackagereleaseID, |
28 | + == SourcePackageReleaseFile.sourcepackagerelease_id, |
29 | SourcePackageReleaseFile.libraryfile |
30 | == LibraryFileAlias.id, |
31 | ] |
32 | @@ -189,7 +189,7 @@ class DeathRow: |
33 | BinaryPackagePublishingHistory.archive == self.archive, |
34 | BinaryPackagePublishingHistory.dateremoved == None, |
35 | BinaryPackagePublishingHistory.binarypackagerelease |
36 | - == BinaryPackageFile.binarypackagereleaseID, |
37 | + == BinaryPackageFile.binarypackagerelease_id, |
38 | BinaryPackageFile.libraryfile == LibraryFileAlias.id, |
39 | ] |
40 | ) |
41 | diff --git a/lib/lp/archivepublisher/model/ftparchive.py b/lib/lp/archivepublisher/model/ftparchive.py |
42 | index 710fee5..a891a85 100644 |
43 | --- a/lib/lp/archivepublisher/model/ftparchive.py |
44 | +++ b/lib/lp/archivepublisher/model/ftparchive.py |
45 | @@ -671,11 +671,11 @@ class FTPArchiveHandler: |
46 | Component.name, |
47 | ) |
48 | join_conditions = [ |
49 | - SourcePackageReleaseFile.sourcepackagereleaseID |
50 | + SourcePackageReleaseFile.sourcepackagerelease_id |
51 | == SourcePackagePublishingHistory.sourcepackagereleaseID, |
52 | SourcePackageName.id |
53 | == SourcePackagePublishingHistory.sourcepackagenameID, |
54 | - LibraryFileAlias.id == SourcePackageReleaseFile.libraryfileID, |
55 | + LibraryFileAlias.id == SourcePackageReleaseFile.libraryfile_id, |
56 | Component.id == SourcePackagePublishingHistory.component_id, |
57 | ] |
58 | select_conditions = [ |
59 | @@ -713,11 +713,11 @@ class FTPArchiveHandler: |
60 | join_conditions = [ |
61 | BinaryPackageRelease.id |
62 | == BinaryPackagePublishingHistory.binarypackagereleaseID, |
63 | - BinaryPackageFile.binarypackagereleaseID |
64 | + BinaryPackageFile.binarypackagerelease_id |
65 | == BinaryPackagePublishingHistory.binarypackagereleaseID, |
66 | BinaryPackageBuild.id == BinaryPackageRelease.buildID, |
67 | SourcePackageName.id == BinaryPackageBuild.source_package_name_id, |
68 | - LibraryFileAlias.id == BinaryPackageFile.libraryfileID, |
69 | + LibraryFileAlias.id == BinaryPackageFile.libraryfile_id, |
70 | DistroArchSeries.id |
71 | == BinaryPackagePublishingHistory.distroarchseriesID, |
72 | Component.id == BinaryPackagePublishingHistory.component_id, |
73 | diff --git a/lib/lp/registry/doc/distribution-mirror.rst b/lib/lp/registry/doc/distribution-mirror.rst |
74 | index 412d2bc..5fd9798 100644 |
75 | --- a/lib/lp/registry/doc/distribution-mirror.rst |
76 | +++ b/lib/lp/registry/doc/distribution-mirror.rst |
77 | @@ -682,8 +682,13 @@ so we need to skip that upload. |
78 | ... time_interval, deb_only=False |
79 | ... ) |
80 | |
81 | - >>> bpf = BinaryPackageFile.selectOneBy( |
82 | - ... binarypackagereleaseID=upload.binarypackagerelease.id |
83 | + >>> bpf = ( |
84 | + ... IStore(BinaryPackageFile) |
85 | + ... .find( |
86 | + ... BinaryPackageFile, |
87 | + ... binarypackagerelease=upload.binarypackagerelease, |
88 | + ... ) |
89 | + ... .one() |
90 | ... ) |
91 | >>> print(upload.binarypackagerelease.version) |
92 | 3.14156 |
93 | diff --git a/lib/lp/registry/model/distributionmirror.py b/lib/lp/registry/model/distributionmirror.py |
94 | index 317d440..7e350cf 100644 |
95 | --- a/lib/lp/registry/model/distributionmirror.py |
96 | +++ b/lib/lp/registry/model/distributionmirror.py |
97 | @@ -981,7 +981,7 @@ class MirrorDistroArchSeries(StormBase, _MirrorSeriesMixIn): |
98 | clauses.extend( |
99 | [ |
100 | BinaryPackagePublishingHistory.binarypackagereleaseID |
101 | - == BinaryPackageFile.binarypackagereleaseID, |
102 | + == BinaryPackageFile.binarypackagerelease_id, |
103 | BinaryPackageFile.filetype == BinaryPackageFileType.DEB, |
104 | ] |
105 | ) |
106 | diff --git a/lib/lp/services/librarian/model.py b/lib/lp/services/librarian/model.py |
107 | index 210ffcf..7aaf5de 100644 |
108 | --- a/lib/lp/services/librarian/model.py |
109 | +++ b/lib/lp/services/librarian/model.py |
110 | @@ -16,7 +16,7 @@ from urllib.parse import urlparse |
111 | |
112 | import pytz |
113 | from lazr.delegates import delegate_to |
114 | -from storm.locals import Date, Desc, Int, Reference, Store |
115 | +from storm.locals import Date, Desc, Int, Reference, ReferenceSet, Store |
116 | from zope.component import adapter, getUtility |
117 | from zope.interface import Interface, implementer |
118 | |
119 | @@ -88,11 +88,11 @@ class LibraryFileAlias(SQLBase): |
120 | intermediateTable="ProductReleaseFile", |
121 | ) |
122 | |
123 | - sourcepackages = SQLRelatedJoin( |
124 | - "SourcePackageRelease", |
125 | - joinColumn="libraryfile", |
126 | - otherColumn="sourcepackagerelease", |
127 | - intermediateTable="SourcePackageReleaseFile", |
128 | + sourcepackages = ReferenceSet( |
129 | + "id", |
130 | + "SourcePackageReleaseFile.libraryfile_id", |
131 | + "SourcePackageReleaseFile.sourcepackagerelease_id", |
132 | + "SourcePackageRelease.id", |
133 | ) |
134 | |
135 | @property |
136 | @@ -206,11 +206,11 @@ class LibraryFileAlias(SQLBase): |
137 | intermediateTable="ProductReleaseFile", |
138 | ) |
139 | |
140 | - sourcepackages = SQLRelatedJoin( |
141 | - "SourcePackageRelease", |
142 | - joinColumn="libraryfile", |
143 | - otherColumn="sourcepackagerelease", |
144 | - intermediateTable="SourcePackageReleaseFile", |
145 | + sourcepackages = ReferenceSet( |
146 | + "id", |
147 | + "SourcePackageReleaseFile.libraryfile_id", |
148 | + "SourcePackageReleaseFile.sourcepackagerelease_id", |
149 | + "SourcePackageRelease.id", |
150 | ) |
151 | |
152 | @property |
153 | diff --git a/lib/lp/soyuz/browser/queue.py b/lib/lp/soyuz/browser/queue.py |
154 | index 2fbcc60..7f12bd3 100644 |
155 | --- a/lib/lp/soyuz/browser/queue.py |
156 | +++ b/lib/lp/soyuz/browser/queue.py |
157 | @@ -225,13 +225,13 @@ class QueueItemsView(LaunchpadView): |
158 | bpbs = load_related(BinaryPackageBuild, pubs, ["build_id"]) |
159 | bprs = load_referencing(BinaryPackageRelease, bpbs, ["buildID"]) |
160 | source_files = load_referencing( |
161 | - SourcePackageReleaseFile, source_sprs, ["sourcepackagereleaseID"] |
162 | + SourcePackageReleaseFile, source_sprs, ["sourcepackagerelease_id"] |
163 | ) |
164 | binary_files = load_referencing( |
165 | - BinaryPackageFile, bprs, ["binarypackagereleaseID"] |
166 | + BinaryPackageFile, bprs, ["binarypackagerelease_id"] |
167 | ) |
168 | file_lfas = load_related( |
169 | - LibraryFileAlias, source_files + binary_files, ["libraryfileID"] |
170 | + LibraryFileAlias, source_files + binary_files, ["libraryfile_id"] |
171 | ) |
172 | load_related(LibraryFileContent, file_lfas, ["contentID"]) |
173 | |
174 | diff --git a/lib/lp/soyuz/doc/build-files.rst b/lib/lp/soyuz/doc/build-files.rst |
175 | index a73a7d8..554f85a 100644 |
176 | --- a/lib/lp/soyuz/doc/build-files.rst |
177 | +++ b/lib/lp/soyuz/doc/build-files.rst |
178 | @@ -79,6 +79,6 @@ We can also retrieve the corresponding BinaryPackageFile: |
179 | |
180 | >>> bpf = build.getBinaryPackageFileByName("test_1.0_all.deb") |
181 | >>> bpf |
182 | - <BinaryPackageFile ...> |
183 | + <...BinaryPackageFile object ...> |
184 | >>> bpf.libraryfile == deb |
185 | True |
186 | diff --git a/lib/lp/soyuz/doc/gina.rst b/lib/lp/soyuz/doc/gina.rst |
187 | index 9d78622..5d5f0c9 100644 |
188 | --- a/lib/lp/soyuz/doc/gina.rst |
189 | +++ b/lib/lp/soyuz/doc/gina.rst |
190 | @@ -328,8 +328,10 @@ And check that its files actually ended up in the librarian (these sha1sums |
191 | were calculated directly on the files): |
192 | |
193 | >>> from lp.soyuz.model.files import SourcePackageReleaseFile |
194 | - >>> files = SourcePackageReleaseFile.selectBy( |
195 | - ... sourcepackagereleaseID=cap.id, orderBy="libraryfile" |
196 | + >>> files = ( |
197 | + ... IStore(SourcePackageReleaseFile) |
198 | + ... .find(SourcePackageReleaseFile, sourcepackagerelease=cap) |
199 | + ... .order_by("libraryfile") |
200 | ... ) |
201 | >>> for f in files: |
202 | ... print(f.libraryfile.content.sha1) |
203 | diff --git a/lib/lp/soyuz/interfaces/files.py b/lib/lp/soyuz/interfaces/files.py |
204 | index 033afd9..85c7d37 100644 |
205 | --- a/lib/lp/soyuz/interfaces/files.py |
206 | +++ b/lib/lp/soyuz/interfaces/files.py |
207 | @@ -24,7 +24,7 @@ class IPackageReleaseFile(Interface): |
208 | |
209 | id = Int(title=_("ID"), required=True, readonly=True) |
210 | |
211 | - libraryfileID = Int( |
212 | + libraryfile_id = Int( |
213 | title=_("The LibraryFileAlias id for this file"), |
214 | required=True, |
215 | readonly=True, |
216 | @@ -52,7 +52,7 @@ class IBinaryPackageFile(IPackageReleaseFile): |
217 | readonly=False, |
218 | ) |
219 | |
220 | - binarypackagereleaseID = Int( |
221 | + binarypackagerelease_id = Int( |
222 | title=_("ID of the binary package release being published"), |
223 | required=True, |
224 | readonly=False, |
225 | @@ -69,7 +69,7 @@ class ISourcePackageReleaseFile(IPackageReleaseFile): |
226 | readonly=False, |
227 | ) |
228 | |
229 | - sourcepackagereleaseID = Int( |
230 | + sourcepackagerelease_id = Int( |
231 | title=_("ID of the source package release being published"), |
232 | required=True, |
233 | readonly=False, |
234 | diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py |
235 | index c04e77f..b74321f 100644 |
236 | --- a/lib/lp/soyuz/model/archive.py |
237 | +++ b/lib/lp/soyuz/model/archive.py |
238 | @@ -870,8 +870,8 @@ class Archive(SQLBase): |
239 | SourcePackagePublishingHistory.archive == self.id, |
240 | SourcePackagePublishingHistory.dateremoved == None, |
241 | SourcePackagePublishingHistory.sourcepackagereleaseID |
242 | - == SourcePackageReleaseFile.sourcepackagereleaseID, |
243 | - SourcePackageReleaseFile.libraryfileID == LibraryFileAlias.id, |
244 | + == SourcePackageReleaseFile.sourcepackagerelease_id, |
245 | + SourcePackageReleaseFile.libraryfile_id == LibraryFileAlias.id, |
246 | LibraryFileAlias.contentID == LibraryFileContent.id, |
247 | ) |
248 | |
249 | @@ -1159,8 +1159,8 @@ class Archive(SQLBase): |
250 | BinaryPackagePublishingHistory.archive == self.id, |
251 | BinaryPackagePublishingHistory.dateremoved == None, |
252 | BinaryPackagePublishingHistory.binarypackagereleaseID |
253 | - == BinaryPackageFile.binarypackagereleaseID, |
254 | - BinaryPackageFile.libraryfileID == LibraryFileAlias.id, |
255 | + == BinaryPackageFile.binarypackagerelease_id, |
256 | + BinaryPackageFile.libraryfile_id == LibraryFileAlias.id, |
257 | LibraryFileAlias.contentID == LibraryFileContent.id, |
258 | ) |
259 | # See `IArchive.sources_size`. |
260 | @@ -1952,15 +1952,15 @@ class Archive(SQLBase): |
261 | clauses = ( |
262 | SourcePackagePublishingHistory.archive == self.id, |
263 | SourcePackagePublishingHistory.sourcepackagereleaseID |
264 | - == SourcePackageReleaseFile.sourcepackagereleaseID, |
265 | - SourcePackageReleaseFile.libraryfileID == LibraryFileAlias.id, |
266 | + == SourcePackageReleaseFile.sourcepackagerelease_id, |
267 | + SourcePackageReleaseFile.libraryfile_id == LibraryFileAlias.id, |
268 | ) |
269 | elif re_isadeb.match(filename): |
270 | clauses = ( |
271 | BinaryPackagePublishingHistory.archive == self.id, |
272 | BinaryPackagePublishingHistory.binarypackagereleaseID |
273 | - == BinaryPackageFile.binarypackagereleaseID, |
274 | - BinaryPackageFile.libraryfileID == LibraryFileAlias.id, |
275 | + == BinaryPackageFile.binarypackagerelease_id, |
276 | + BinaryPackageFile.libraryfile_id == LibraryFileAlias.id, |
277 | ) |
278 | elif filename.endswith(".changes"): |
279 | clauses = ( |
280 | @@ -2013,8 +2013,8 @@ class Archive(SQLBase): |
281 | SourcePackageName.name == name, |
282 | Cast(SourcePackageRelease.version, "text") == version, |
283 | SourcePackageRelease.id |
284 | - == SourcePackageReleaseFile.sourcepackagereleaseID, |
285 | - SourcePackageReleaseFile.libraryfileID == LibraryFileAlias.id, |
286 | + == SourcePackageReleaseFile.sourcepackagerelease_id, |
287 | + SourcePackageReleaseFile.libraryfile_id == LibraryFileAlias.id, |
288 | LibraryFileAlias.filename == filename, |
289 | LibraryFileAlias.content != None, |
290 | ) |
291 | @@ -2061,7 +2061,7 @@ class Archive(SQLBase): |
292 | BinaryPackageBuild.source_package_name |
293 | == SourcePackageName.id, |
294 | BinaryPackagePublishingHistory.binarypackagerelease |
295 | - == BinaryPackageFile.binarypackagereleaseID, |
296 | + == BinaryPackageFile.binarypackagerelease_id, |
297 | ] |
298 | ) |
299 | else: |
300 | @@ -2072,7 +2072,7 @@ class Archive(SQLBase): |
301 | SourcePackagePublishingHistory.sourcepackagename |
302 | == SourcePackageName.id, |
303 | SourcePackagePublishingHistory.sourcepackagerelease |
304 | - == SourcePackageReleaseFile.sourcepackagereleaseID, |
305 | + == SourcePackageReleaseFile.sourcepackagerelease_id, |
306 | ] |
307 | ) |
308 | clauses.extend( |
309 | @@ -2120,9 +2120,9 @@ class Archive(SQLBase): |
310 | IStore(BinaryPackageRelease) |
311 | .find( |
312 | BinaryPackageRelease, |
313 | - BinaryPackageFile.binarypackagereleaseID |
314 | + BinaryPackageFile.binarypackagerelease_id |
315 | == BinaryPackageRelease.id, |
316 | - BinaryPackageFile.libraryfileID == LibraryFileAlias.id, |
317 | + BinaryPackageFile.libraryfile_id == LibraryFileAlias.id, |
318 | LibraryFileAlias.filename == filename, |
319 | BinaryPackagePublishingHistory.archive == self, |
320 | BinaryPackagePublishingHistory.binarypackagereleaseID |
321 | @@ -2855,8 +2855,8 @@ class Archive(SQLBase): |
322 | (LibraryFileAlias.filename, LibraryFileContent.sha1), |
323 | SourcePackagePublishingHistory.archive == self, |
324 | SourcePackagePublishingHistory.sourcepackagerelease |
325 | - == SourcePackageReleaseFile.sourcepackagereleaseID, |
326 | - LibraryFileAlias.id == SourcePackageReleaseFile.libraryfileID, |
327 | + == SourcePackageReleaseFile.sourcepackagerelease_id, |
328 | + LibraryFileAlias.id == SourcePackageReleaseFile.libraryfile_id, |
329 | LibraryFileAlias.filename.is_in(source_files), |
330 | LibraryFileContent.id == LibraryFileAlias.contentID, |
331 | ) |
332 | diff --git a/lib/lp/soyuz/model/binarypackagebuild.py b/lib/lp/soyuz/model/binarypackagebuild.py |
333 | index a8d4352..5471460 100644 |
334 | --- a/lib/lp/soyuz/model/binarypackagebuild.py |
335 | +++ b/lib/lp/soyuz/model/binarypackagebuild.py |
336 | @@ -436,8 +436,8 @@ class BinaryPackageBuild(PackageBuildMixin, SQLBase): |
337 | ), |
338 | BinaryPackageRelease.build == self, |
339 | BinaryPackageRelease.id |
340 | - == BinaryPackageFile.binarypackagereleaseID, |
341 | - LibraryFileAlias.id == BinaryPackageFile.libraryfileID, |
342 | + == BinaryPackageFile.binarypackagerelease_id, |
343 | + LibraryFileAlias.id == BinaryPackageFile.libraryfile_id, |
344 | LibraryFileContent.id == LibraryFileAlias.contentID, |
345 | ) |
346 | return result.order_by( |
347 | @@ -796,7 +796,7 @@ class BinaryPackageBuild(PackageBuildMixin, SQLBase): |
348 | BinaryPackageRelease.build == self.id, |
349 | BinaryPackageFile.binarypackagerelease |
350 | == BinaryPackageRelease.id, |
351 | - LibraryFileAlias.id == BinaryPackageFile.libraryfileID, |
352 | + LibraryFileAlias.id == BinaryPackageFile.libraryfile_id, |
353 | LibraryFileAlias.filename == filename, |
354 | ) |
355 | .one() |
356 | @@ -1576,7 +1576,7 @@ class BinaryPackageBuildMacaroonIssuer(MacaroonIssuerBase): |
357 | clauses.extend( |
358 | [ |
359 | BinaryPackageBuild.source_package_release_id |
360 | - == SourcePackageReleaseFile.sourcepackagereleaseID, |
361 | + == SourcePackageReleaseFile.sourcepackagerelease_id, |
362 | SourcePackageReleaseFile.libraryfile == context, |
363 | ] |
364 | ) |
365 | diff --git a/lib/lp/soyuz/model/files.py b/lib/lp/soyuz/model/files.py |
366 | index a54a779..4145321 100644 |
367 | --- a/lib/lp/soyuz/model/files.py |
368 | +++ b/lib/lp/soyuz/model/files.py |
369 | @@ -7,12 +7,12 @@ __all__ = [ |
370 | "SourcePackageReleaseFile", |
371 | ] |
372 | |
373 | +from storm.locals import Int, Reference |
374 | from zope.interface import implementer |
375 | |
376 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType |
377 | from lp.services.database.enumcol import DBEnum |
378 | -from lp.services.database.sqlbase import SQLBase |
379 | -from lp.services.database.sqlobject import ForeignKey |
380 | +from lp.services.database.stormbase import StormBase |
381 | from lp.soyuz.enums import BinaryPackageFileType |
382 | from lp.soyuz.interfaces.files import ( |
383 | IBinaryPackageFile, |
384 | @@ -21,20 +21,29 @@ from lp.soyuz.interfaces.files import ( |
385 | |
386 | |
387 | @implementer(IBinaryPackageFile) |
388 | -class BinaryPackageFile(SQLBase): |
389 | +class BinaryPackageFile(StormBase): |
390 | """See IBinaryPackageFile""" |
391 | |
392 | - _table = "BinaryPackageFile" |
393 | + __storm_table__ = "BinaryPackageFile" |
394 | |
395 | - binarypackagerelease = ForeignKey( |
396 | - dbName="binarypackagerelease", |
397 | - foreignKey="BinaryPackageRelease", |
398 | - notNull=True, |
399 | + id = Int(primary=True) |
400 | + binarypackagerelease_id = Int( |
401 | + name="binarypackagerelease", allow_none=False |
402 | ) |
403 | - libraryfile = ForeignKey( |
404 | - dbName="libraryfile", foreignKey="LibraryFileAlias", notNull=True |
405 | + binarypackagerelease = Reference( |
406 | + binarypackagerelease_id, "BinaryPackageRelease.id" |
407 | ) |
408 | - filetype = DBEnum(name="filetype", enum=BinaryPackageFileType) |
409 | + libraryfile_id = Int(name="libraryfile", allow_none=False) |
410 | + libraryfile = Reference(libraryfile_id, "LibraryFileAlias.id") |
411 | + filetype = DBEnum( |
412 | + name="filetype", enum=BinaryPackageFileType, allow_none=False |
413 | + ) |
414 | + |
415 | + def __init__(self, binarypackagerelease, libraryfile, filetype): |
416 | + super().__init__() |
417 | + self.binarypackagerelease = binarypackagerelease |
418 | + self.libraryfile = libraryfile |
419 | + self.filetype = filetype |
420 | |
421 | |
422 | class SourceFileMixin: |
423 | @@ -51,13 +60,26 @@ class SourceFileMixin: |
424 | |
425 | |
426 | @implementer(ISourcePackageReleaseFile) |
427 | -class SourcePackageReleaseFile(SourceFileMixin, SQLBase): |
428 | +class SourcePackageReleaseFile(SourceFileMixin, StormBase): |
429 | """See ISourcePackageFile""" |
430 | |
431 | - sourcepackagerelease = ForeignKey( |
432 | - foreignKey="SourcePackageRelease", dbName="sourcepackagerelease" |
433 | + __storm_table__ = "SourcePackageReleaseFile" |
434 | + |
435 | + id = Int(primary=True) |
436 | + sourcepackagerelease_id = Int( |
437 | + name="sourcepackagerelease", allow_none=False |
438 | ) |
439 | - libraryfile = ForeignKey( |
440 | - foreignKey="LibraryFileAlias", dbName="libraryfile" |
441 | + sourcepackagerelease = Reference( |
442 | + sourcepackagerelease_id, "SourcePackageRelease.id" |
443 | ) |
444 | - filetype = DBEnum(enum=SourcePackageFileType) |
445 | + libraryfile_id = Int(name="libraryfile", allow_none=False) |
446 | + libraryfile = Reference(libraryfile_id, "LibraryFileAlias.id") |
447 | + filetype = DBEnum( |
448 | + name="filetype", enum=SourcePackageFileType, allow_none=False |
449 | + ) |
450 | + |
451 | + def __init__(self, sourcepackagerelease, libraryfile, filetype): |
452 | + super().__init__() |
453 | + self.sourcepackagerelease = sourcepackagerelease |
454 | + self.libraryfile = libraryfile |
455 | + self.filetype = filetype |
456 | diff --git a/lib/lp/soyuz/model/packagediff.py b/lib/lp/soyuz/model/packagediff.py |
457 | index 92677ef..1eb35fe 100644 |
458 | --- a/lib/lp/soyuz/model/packagediff.py |
459 | +++ b/lib/lp/soyuz/model/packagediff.py |
460 | @@ -195,10 +195,10 @@ class PackageDiff(StormBase): |
461 | IStore(LibraryFileAlias) |
462 | .find( |
463 | LibraryFileAlias.id, |
464 | - SourcePackageReleaseFile.sourcepackagereleaseID.is_in( |
465 | + SourcePackageReleaseFile.sourcepackagerelease_id.is_in( |
466 | (self.from_source_id, self.to_source_id) |
467 | ), |
468 | - SourcePackageReleaseFile.libraryfileID == LibraryFileAlias.id, |
469 | + SourcePackageReleaseFile.libraryfile_id == LibraryFileAlias.id, |
470 | LibraryFileAlias.content == None, |
471 | ) |
472 | .count() |
473 | diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py |
474 | index 1df1fa6..b2f7a9d 100644 |
475 | --- a/lib/lp/soyuz/model/publishing.py |
476 | +++ b/lib/lp/soyuz/model/publishing.py |
477 | @@ -385,7 +385,7 @@ class SourcePackagePublishingHistory(SQLBase, ArchivePublisherBase): |
478 | bpfs = list( |
479 | Store.of(self).find( |
480 | BinaryPackageFile, |
481 | - BinaryPackageFile.binarypackagereleaseID.is_in(bpr_ids), |
482 | + BinaryPackageFile.binarypackagerelease_id.is_in(bpr_ids), |
483 | ) |
484 | ) |
485 | bpfs_by_bpr = defaultdict(list) |
486 | @@ -395,7 +395,7 @@ class SourcePackagePublishingHistory(SQLBase, ArchivePublisherBase): |
487 | get_property_cache(bpr).files = bpfs_by_bpr[bpr] |
488 | |
489 | # Preload LibraryFileAliases. |
490 | - lfa_ids = {bpf.libraryfileID for bpf in bpfs} |
491 | + lfa_ids = {bpf.libraryfile_id for bpf in bpfs} |
492 | list( |
493 | Store.of(self).find( |
494 | LibraryFileAlias, LibraryFileAlias.id.is_in(lfa_ids) |
495 | @@ -476,7 +476,7 @@ class SourcePackagePublishingHistory(SQLBase, ArchivePublisherBase): |
496 | def files(self): |
497 | """See `IPublishing`.""" |
498 | files = self.sourcepackagerelease.files |
499 | - lfas = bulk.load_related(LibraryFileAlias, files, ["libraryfileID"]) |
500 | + lfas = bulk.load_related(LibraryFileAlias, files, ["libraryfile_id"]) |
501 | bulk.load_related(LibraryFileContent, lfas, ["contentID"]) |
502 | return files |
503 | |
504 | @@ -659,7 +659,7 @@ class SourcePackagePublishingHistory(SQLBase, ArchivePublisherBase): |
505 | sources = Store.of(self).find( |
506 | (LibraryFileAlias, LibraryFileContent), |
507 | LibraryFileContent.id == LibraryFileAlias.contentID, |
508 | - LibraryFileAlias.id == SourcePackageReleaseFile.libraryfileID, |
509 | + LibraryFileAlias.id == SourcePackageReleaseFile.libraryfile_id, |
510 | SourcePackageReleaseFile.sourcepackagerelease |
511 | == self.sourcepackagereleaseID, |
512 | ) |
513 | @@ -834,7 +834,7 @@ class BinaryPackagePublishingHistory(SQLBase, ArchivePublisherBase): |
514 | def files(self): |
515 | """See `IPublishing`.""" |
516 | files = self.binarypackagerelease.files |
517 | - lfas = bulk.load_related(LibraryFileAlias, files, ["libraryfileID"]) |
518 | + lfas = bulk.load_related(LibraryFileAlias, files, ["libraryfile_id"]) |
519 | bulk.load_related(LibraryFileContent, lfas, ["contentID"]) |
520 | return files |
521 | |
522 | @@ -1254,7 +1254,7 @@ class BinaryPackagePublishingHistory(SQLBase, ArchivePublisherBase): |
523 | binaries = Store.of(self).find( |
524 | (LibraryFileAlias, LibraryFileContent), |
525 | LibraryFileContent.id == LibraryFileAlias.contentID, |
526 | - LibraryFileAlias.id == BinaryPackageFile.libraryfileID, |
527 | + LibraryFileAlias.id == BinaryPackageFile.libraryfile_id, |
528 | BinaryPackageFile.binarypackagerelease |
529 | == self.binarypackagereleaseID, |
530 | ) |
531 | @@ -1848,7 +1848,7 @@ class PublishingSet: |
532 | LibraryFileContent, |
533 | ), |
534 | LibraryFileContent.id == LibraryFileAlias.contentID, |
535 | - LibraryFileAlias.id == BinaryPackageFile.libraryfileID, |
536 | + LibraryFileAlias.id == BinaryPackageFile.libraryfile_id, |
537 | BinaryPackageFile.binarypackagerelease == BinaryPackageRelease.id, |
538 | BinaryPackageRelease.buildID == BinaryPackageBuild.id, |
539 | SourcePackagePublishingHistory.sourcepackagereleaseID |
540 | @@ -1876,7 +1876,7 @@ class PublishingSet: |
541 | LibraryFileContent, |
542 | ), |
543 | LibraryFileContent.id == LibraryFileAlias.contentID, |
544 | - LibraryFileAlias.id == SourcePackageReleaseFile.libraryfileID, |
545 | + LibraryFileAlias.id == SourcePackageReleaseFile.libraryfile_id, |
546 | SourcePackageReleaseFile.sourcepackagerelease |
547 | == SourcePackagePublishingHistory.sourcepackagereleaseID, |
548 | SourcePackagePublishingHistory.id.is_in(source_publication_ids), |
549 | @@ -2005,11 +2005,11 @@ class PublishingSet: |
550 | IStore(SourcePackageReleaseFile) |
551 | .find( |
552 | SourcePackageReleaseFile, |
553 | - SourcePackageReleaseFile.sourcepackagereleaseID.is_in( |
554 | + SourcePackageReleaseFile.sourcepackagerelease_id.is_in( |
555 | spr_ids |
556 | ), |
557 | ) |
558 | - .order_by(SourcePackageReleaseFile.libraryfileID) |
559 | + .order_by(SourcePackageReleaseFile.libraryfile_id) |
560 | ) |
561 | file_map = defaultdict(list) |
562 | for sprf in sprfs: |
563 | @@ -2017,7 +2017,7 @@ class PublishingSet: |
564 | for spr, files in file_map.items(): |
565 | get_property_cache(spr).files = files |
566 | lfas = bulk.load_related( |
567 | - LibraryFileAlias, sprfs, ["libraryfileID"] |
568 | + LibraryFileAlias, sprfs, ["libraryfile_id"] |
569 | ) |
570 | bulk.load_related(LibraryFileContent, lfas, ["contentID"]) |
571 | |
572 | @@ -2063,14 +2063,16 @@ class PublishingSet: |
573 | SourcePackageRelease, bpbs, ["source_package_release_id"] |
574 | ) |
575 | bpfs = bulk.load_referencing( |
576 | - BinaryPackageFile, bprs, ["binarypackagereleaseID"] |
577 | + BinaryPackageFile, bprs, ["binarypackagerelease_id"] |
578 | ) |
579 | file_map = defaultdict(list) |
580 | for bpf in bpfs: |
581 | file_map[bpf.binarypackagerelease].append(bpf) |
582 | for bpr, files in file_map.items(): |
583 | get_property_cache(bpr).files = files |
584 | - lfas = bulk.load_related(LibraryFileAlias, bpfs, ["libraryfileID"]) |
585 | + lfas = bulk.load_related( |
586 | + LibraryFileAlias, bpfs, ["libraryfile_id"] |
587 | + ) |
588 | bulk.load_related(LibraryFileContent, lfas, ["contentID"]) |
589 | bulk.load_related(SourcePackageName, sprs, ["sourcepackagenameID"]) |
590 | bulk.load_related(BinaryPackageName, bprs, ["binarypackagenameID"]) |
591 | diff --git a/lib/lp/soyuz/model/sourcepackagerelease.py b/lib/lp/soyuz/model/sourcepackagerelease.py |
592 | index 0dcd8da..9cb4baf 100644 |
593 | --- a/lib/lp/soyuz/model/sourcepackagerelease.py |
594 | +++ b/lib/lp/soyuz/model/sourcepackagerelease.py |
595 | @@ -305,7 +305,7 @@ class SourcePackageRelease(SQLBase): |
596 | return list( |
597 | Store.of(self) |
598 | .find(SourcePackageReleaseFile, sourcepackagerelease=self) |
599 | - .order_by(SourcePackageReleaseFile.libraryfileID) |
600 | + .order_by(SourcePackageReleaseFile.libraryfile_id) |
601 | ) |
602 | |
603 | def getFileByName(self, filename): |
604 | @@ -315,7 +315,7 @@ class SourcePackageRelease(SQLBase): |
605 | .find( |
606 | SourcePackageReleaseFile, |
607 | SourcePackageReleaseFile.sourcepackagerelease == self.id, |
608 | - LibraryFileAlias.id == SourcePackageReleaseFile.libraryfileID, |
609 | + LibraryFileAlias.id == SourcePackageReleaseFile.libraryfile_id, |
610 | LibraryFileAlias.filename == filename, |
611 | ) |
612 | .one() |
613 | diff --git a/lib/lp/soyuz/scripts/expire_archive_files.py b/lib/lp/soyuz/scripts/expire_archive_files.py |
614 | index ed91efc..ef82fef 100755 |
615 | --- a/lib/lp/soyuz/scripts/expire_archive_files.py |
616 | +++ b/lib/lp/soyuz/scripts/expire_archive_files.py |
617 | @@ -126,7 +126,7 @@ class ArchiveExpirer(LaunchpadCronScript): |
618 | ), |
619 | ) |
620 | denied = Select( |
621 | - xPF.libraryfileID, |
622 | + xPF.libraryfile_id, |
623 | where=And( |
624 | xPR_join, |
625 | xPPH.archive == Archive.id, |
626 | diff --git a/lib/lp/soyuz/scripts/gina/handlers.py b/lib/lp/soyuz/scripts/gina/handlers.py |
627 | index 1e0ff96..a595340 100644 |
628 | --- a/lib/lp/soyuz/scripts/gina/handlers.py |
629 | +++ b/lib/lp/soyuz/scripts/gina/handlers.py |
630 | @@ -916,7 +916,7 @@ class BinaryPackageHandler: |
631 | |
632 | alias = getLibraryAlias(path, fname) |
633 | BinaryPackageFile( |
634 | - binarypackagerelease=binpkg.id, |
635 | + binarypackagerelease=binpkg, |
636 | libraryfile=alias, |
637 | filetype=determine_binary_file_type(fname), |
638 | ) |
LGTM 👍