Merge ~cjwatson/launchpad:registry-dbenum into launchpad:master
- Git
- lp:~cjwatson/launchpad
- registry-dbenum
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 66f6e70e0dadbed289a2d260cb0ff018aa3975bc |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:registry-dbenum |
Merge into: | launchpad:master |
Diff against target: |
619 lines (+107/-109) 16 files modified
lib/lp/registry/model/distribution.py (+16/-17) lib/lp/registry/model/distributionmirror.py (+18/-15) lib/lp/registry/model/distroseries.py (+3/-3) lib/lp/registry/model/distroseriesparent.py (+3/-4) lib/lp/registry/model/gpgkey.py (+3/-3) lib/lp/registry/model/packaging.py (+2/-3) lib/lp/registry/model/person.py (+13/-12) lib/lp/registry/model/persontransferjob.py (+2/-2) lib/lp/registry/model/product.py (+23/-27) lib/lp/registry/model/productjob.py (+2/-2) lib/lp/registry/model/productlicense.py (+2/-2) lib/lp/registry/model/productrelease.py (+3/-3) lib/lp/registry/model/productseries.py (+8/-8) lib/lp/registry/model/projectgroup.py (+4/-3) lib/lp/registry/model/sharingjob.py (+2/-2) lib/lp/registry/model/teammembership.py (+3/-3) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jürgen Gmach | Approve | ||
Review via email: mp+412091@code.launchpad.net |
Commit message
lp.registry: Use DBEnum rather than EnumCol
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/registry/model/distribution.py b/lib/lp/registry/model/distribution.py |
2 | index 4f00e9b..dc9838f 100644 |
3 | --- a/lib/lp/registry/model/distribution.py |
4 | +++ b/lib/lp/registry/model/distribution.py |
5 | @@ -146,7 +146,7 @@ from lp.services.database.bulk import load_referencing |
6 | from lp.services.database.constants import UTC_NOW |
7 | from lp.services.database.datetimecol import UtcDateTimeCol |
8 | from lp.services.database.decoratedresultset import DecoratedResultSet |
9 | -from lp.services.database.enumcol import EnumCol |
10 | +from lp.services.database.enumcol import DBEnum |
11 | from lp.services.database.interfaces import IStore |
12 | from lp.services.database.sqlbase import ( |
13 | SQLBase, |
14 | @@ -262,9 +262,9 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements, |
15 | translationgroup = ForeignKey( |
16 | dbName='translationgroup', foreignKey='TranslationGroup', |
17 | notNull=False, default=None) |
18 | - translationpermission = EnumCol( |
19 | - dbName='translationpermission', notNull=True, |
20 | - schema=TranslationPermission, default=TranslationPermission.OPEN) |
21 | + translationpermission = DBEnum( |
22 | + name='translationpermission', allow_none=False, |
23 | + enum=TranslationPermission, default=TranslationPermission.OPEN) |
24 | active = True |
25 | official_packages = BoolCol(notNull=True, default=False) |
26 | supports_ppas = BoolCol(notNull=True, default=False) |
27 | @@ -272,9 +272,9 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements, |
28 | package_derivatives_email = StringCol(notNull=False, default=None) |
29 | redirect_release_uploads = BoolCol(notNull=True, default=False) |
30 | development_series_alias = StringCol(notNull=False, default=None) |
31 | - vcs = EnumCol(enum=VCSType, notNull=False) |
32 | - default_traversal_policy = EnumCol( |
33 | - enum=DistributionDefaultTraversalPolicy, notNull=False, |
34 | + vcs = DBEnum(enum=VCSType, allow_none=True) |
35 | + default_traversal_policy = DBEnum( |
36 | + enum=DistributionDefaultTraversalPolicy, allow_none=True, |
37 | default=DistributionDefaultTraversalPolicy.SERIES) |
38 | redirect_default_traversal = BoolCol(notNull=False, default=False) |
39 | oci_registry_credentials_id = Int(name='oci_credentials', allow_none=True) |
40 | @@ -379,9 +379,9 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements, |
41 | self.translations_usage == ServiceUsage.LAUNCHPAD, |
42 | self.official_blueprints, self.official_answers) |
43 | |
44 | - _answers_usage = EnumCol( |
45 | - dbName="answers_usage", notNull=True, |
46 | - schema=ServiceUsage, default=ServiceUsage.UNKNOWN) |
47 | + _answers_usage = DBEnum( |
48 | + name="answers_usage", allow_none=False, |
49 | + enum=ServiceUsage, default=ServiceUsage.UNKNOWN) |
50 | |
51 | def _get_answers_usage(self): |
52 | if self._answers_usage != ServiceUsage.UNKNOWN: |
53 | @@ -403,10 +403,9 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements, |
54 | _set_answers_usage, |
55 | doc="Indicates if the product uses the answers service.") |
56 | |
57 | - _blueprints_usage = EnumCol( |
58 | - dbName="blueprints_usage", notNull=True, |
59 | - schema=ServiceUsage, |
60 | - default=ServiceUsage.UNKNOWN) |
61 | + _blueprints_usage = DBEnum( |
62 | + name="blueprints_usage", allow_none=False, |
63 | + enum=ServiceUsage, default=ServiceUsage.UNKNOWN) |
64 | |
65 | def _get_blueprints_usage(self): |
66 | if self._blueprints_usage != ServiceUsage.UNKNOWN: |
67 | @@ -428,9 +427,9 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements, |
68 | _set_blueprints_usage, |
69 | doc="Indicates if the product uses the blueprints service.") |
70 | |
71 | - translations_usage = EnumCol( |
72 | - dbName="translations_usage", notNull=True, |
73 | - schema=ServiceUsage, default=ServiceUsage.UNKNOWN) |
74 | + translations_usage = DBEnum( |
75 | + name="translations_usage", allow_none=False, |
76 | + enum=ServiceUsage, default=ServiceUsage.UNKNOWN) |
77 | |
78 | @property |
79 | def codehosting_usage(self): |
80 | diff --git a/lib/lp/registry/model/distributionmirror.py b/lib/lp/registry/model/distributionmirror.py |
81 | index 85e44ba..8d3bd82 100644 |
82 | --- a/lib/lp/registry/model/distributionmirror.py |
83 | +++ b/lib/lp/registry/model/distributionmirror.py |
84 | @@ -62,7 +62,7 @@ from lp.registry.interfaces.sourcepackage import SourcePackageFileType |
85 | from lp.services.config import config |
86 | from lp.services.database.constants import UTC_NOW |
87 | from lp.services.database.datetimecol import UtcDateTimeCol |
88 | -from lp.services.database.enumcol import EnumCol |
89 | +from lp.services.database.enumcol import DBEnum |
90 | from lp.services.database.interfaces import IStore |
91 | from lp.services.database.sqlbase import ( |
92 | SQLBase, |
93 | @@ -136,16 +136,17 @@ class DistributionMirror(SQLBase): |
94 | notNull=False, default=None, unique=True) |
95 | enabled = BoolCol( |
96 | notNull=True, default=False) |
97 | - speed = EnumCol( |
98 | - notNull=True, enum=MirrorSpeed) |
99 | + speed = DBEnum( |
100 | + allow_none=False, enum=MirrorSpeed) |
101 | country = ForeignKey( |
102 | dbName='country', foreignKey='Country', notNull=True) |
103 | - content = EnumCol( |
104 | - notNull=True, enum=MirrorContent) |
105 | + content = DBEnum( |
106 | + allow_none=False, enum=MirrorContent) |
107 | official_candidate = BoolCol( |
108 | notNull=True, default=False) |
109 | - status = EnumCol( |
110 | - notNull=True, default=MirrorStatus.PENDING_REVIEW, enum=MirrorStatus) |
111 | + status = DBEnum( |
112 | + allow_none=False, default=MirrorStatus.PENDING_REVIEW, |
113 | + enum=MirrorStatus) |
114 | date_created = UtcDateTimeCol(notNull=True, default=UTC_NOW) |
115 | date_reviewed = UtcDateTimeCol(default=None) |
116 | whiteboard = StringCol( |
117 | @@ -821,10 +822,11 @@ class MirrorDistroArchSeries(SQLBase, _MirrorSeriesMixIn): |
118 | notNull=True) |
119 | component = ForeignKey( |
120 | dbName='component', foreignKey='Component', notNull=True) |
121 | - freshness = EnumCol( |
122 | - notNull=True, default=MirrorFreshness.UNKNOWN, enum=MirrorFreshness) |
123 | - pocket = EnumCol( |
124 | - notNull=True, schema=PackagePublishingPocket) |
125 | + freshness = DBEnum( |
126 | + allow_none=False, default=MirrorFreshness.UNKNOWN, |
127 | + enum=MirrorFreshness) |
128 | + pocket = DBEnum( |
129 | + allow_none=False, enum=PackagePublishingPocket) |
130 | |
131 | def getLatestPublishingEntry(self, time_interval, deb_only=True): |
132 | """Return the BinaryPackagePublishingHistory record with the |
133 | @@ -894,10 +896,11 @@ class MirrorDistroSeriesSource(SQLBase, _MirrorSeriesMixIn): |
134 | notNull=True) |
135 | component = ForeignKey( |
136 | dbName='component', foreignKey='Component', notNull=True) |
137 | - freshness = EnumCol( |
138 | - notNull=True, default=MirrorFreshness.UNKNOWN, enum=MirrorFreshness) |
139 | - pocket = EnumCol( |
140 | - notNull=True, schema=PackagePublishingPocket) |
141 | + freshness = DBEnum( |
142 | + allow_none=False, default=MirrorFreshness.UNKNOWN, |
143 | + enum=MirrorFreshness) |
144 | + pocket = DBEnum( |
145 | + allow_none=False, enum=PackagePublishingPocket) |
146 | |
147 | def getLatestPublishingEntry(self, time_interval): |
148 | clauses = [ |
149 | diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py |
150 | index be223c7..2ad609c 100644 |
151 | --- a/lib/lp/registry/model/distroseries.py |
152 | +++ b/lib/lp/registry/model/distroseries.py |
153 | @@ -97,7 +97,7 @@ from lp.services.database.constants import ( |
154 | ) |
155 | from lp.services.database.datetimecol import UtcDateTimeCol |
156 | from lp.services.database.decoratedresultset import DecoratedResultSet |
157 | -from lp.services.database.enumcol import EnumCol |
158 | +from lp.services.database.enumcol import DBEnum |
159 | from lp.services.database.interfaces import IStore |
160 | from lp.services.database.sqlbase import ( |
161 | SQLBase, |
162 | @@ -234,8 +234,8 @@ class DistroSeries(SQLBase, BugTargetBase, HasSpecificationsMixin, |
163 | title = StringCol(notNull=True) |
164 | description = StringCol(notNull=True) |
165 | version = StringCol(notNull=True) |
166 | - status = EnumCol( |
167 | - dbName='releasestatus', notNull=True, schema=SeriesStatus) |
168 | + status = DBEnum( |
169 | + name='releasestatus', allow_none=False, enum=SeriesStatus) |
170 | date_created = UtcDateTimeCol(notNull=False, default=UTC_NOW) |
171 | datereleased = UtcDateTimeCol(notNull=False, default=None) |
172 | previous_series = ForeignKey( |
173 | diff --git a/lib/lp/registry/model/distroseriesparent.py b/lib/lp/registry/model/distroseriesparent.py |
174 | index a632004..6b30664 100644 |
175 | --- a/lib/lp/registry/model/distroseriesparent.py |
176 | +++ b/lib/lp/registry/model/distroseriesparent.py |
177 | @@ -22,7 +22,7 @@ from lp.registry.interfaces.distroseriesparent import ( |
178 | IDistroSeriesParentSet, |
179 | ) |
180 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
181 | -from lp.services.database.enumcol import EnumCol |
182 | +from lp.services.database.enumcol import DBEnum |
183 | from lp.services.database.interfaces import ( |
184 | IMasterStore, |
185 | IStore, |
186 | @@ -47,9 +47,8 @@ class DistroSeriesParent(Storm): |
187 | is_overlay = Bool(allow_none=False, default=False) |
188 | inherit_overrides = Bool(allow_none=False, default=False) |
189 | |
190 | - pocket = EnumCol( |
191 | - dbName='pocket', notNull=False, |
192 | - schema=PackagePublishingPocket) |
193 | + pocket = DBEnum( |
194 | + name='pocket', allow_none=True, enum=PackagePublishingPocket) |
195 | |
196 | component_id = Int(name='component', allow_none=True) |
197 | component = Reference(component_id, 'Component.id') |
198 | diff --git a/lib/lp/registry/model/gpgkey.py b/lib/lp/registry/model/gpgkey.py |
199 | index a786891..48aa4e7 100644 |
200 | --- a/lib/lp/registry/model/gpgkey.py |
201 | +++ b/lib/lp/registry/model/gpgkey.py |
202 | @@ -10,7 +10,7 @@ from lp.registry.interfaces.gpg import ( |
203 | IGPGKey, |
204 | IGPGKeySet, |
205 | ) |
206 | -from lp.services.database.enumcol import EnumCol |
207 | +from lp.services.database.enumcol import DBEnum |
208 | from lp.services.database.sqlbase import ( |
209 | SQLBase, |
210 | sqlvalues, |
211 | @@ -40,8 +40,8 @@ class GPGKey(SQLBase): |
212 | |
213 | keysize = IntCol(dbName='keysize', notNull=True) |
214 | |
215 | - algorithm = EnumCol(dbName='algorithm', notNull=True, |
216 | - enum=GPGKeyAlgorithm) |
217 | + algorithm = DBEnum(name='algorithm', allow_none=False, |
218 | + enum=GPGKeyAlgorithm) |
219 | |
220 | active = BoolCol(dbName='active', notNull=True) |
221 | |
222 | diff --git a/lib/lp/registry/model/packaging.py b/lib/lp/registry/model/packaging.py |
223 | index 9e40e22..6c7aacf 100644 |
224 | --- a/lib/lp/registry/model/packaging.py |
225 | +++ b/lib/lp/registry/model/packaging.py |
226 | @@ -26,7 +26,7 @@ from lp.services.database.constants import ( |
227 | UTC_NOW, |
228 | ) |
229 | from lp.services.database.datetimecol import UtcDateTimeCol |
230 | -from lp.services.database.enumcol import EnumCol |
231 | +from lp.services.database.enumcol import DBEnum |
232 | from lp.services.database.sqlbase import SQLBase |
233 | from lp.services.database.sqlobject import ForeignKey |
234 | from lp.services.webapp.interfaces import ILaunchBag |
235 | @@ -48,8 +48,7 @@ class Packaging(SQLBase): |
236 | distroseries = ForeignKey(foreignKey='DistroSeries', |
237 | dbName='distroseries', |
238 | notNull=True) |
239 | - packaging = EnumCol(dbName='packaging', notNull=True, |
240 | - enum=PackagingType) |
241 | + packaging = DBEnum(name='packaging', allow_none=False, enum=PackagingType) |
242 | datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW) |
243 | owner = ForeignKey( |
244 | dbName='owner', foreignKey='Person', |
245 | diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py |
246 | index 4d0dcdc..b9f519e 100644 |
247 | --- a/lib/lp/registry/model/person.py |
248 | +++ b/lib/lp/registry/model/person.py |
249 | @@ -249,7 +249,7 @@ from lp.services.database import ( |
250 | from lp.services.database.constants import UTC_NOW |
251 | from lp.services.database.datetimecol import UtcDateTimeCol |
252 | from lp.services.database.decoratedresultset import DecoratedResultSet |
253 | -from lp.services.database.enumcol import EnumCol |
254 | +from lp.services.database.enumcol import DBEnum |
255 | from lp.services.database.interfaces import IStore |
256 | from lp.services.database.policy import PrimaryDatabasePolicy |
257 | from lp.services.database.sqlbase import ( |
258 | @@ -597,24 +597,24 @@ class Person( |
259 | |
260 | sshkeys = SQLMultipleJoin('SSHKey', joinColumn='person') |
261 | |
262 | - renewal_policy = EnumCol( |
263 | + renewal_policy = DBEnum( |
264 | enum=TeamMembershipRenewalPolicy, |
265 | default=TeamMembershipRenewalPolicy.NONE) |
266 | - membership_policy = EnumCol( |
267 | - dbName='subscriptionpolicy', enum=TeamMembershipPolicy, |
268 | + membership_policy = DBEnum( |
269 | + name='subscriptionpolicy', enum=TeamMembershipPolicy, |
270 | default=TeamMembershipPolicy.RESTRICTED, |
271 | - storm_validator=validate_membership_policy) |
272 | + validator=validate_membership_policy) |
273 | defaultrenewalperiod = IntCol(dbName='defaultrenewalperiod', default=None) |
274 | defaultmembershipperiod = IntCol( |
275 | dbName='defaultmembershipperiod', default=None) |
276 | - mailing_list_auto_subscribe_policy = EnumCol( |
277 | + mailing_list_auto_subscribe_policy = DBEnum( |
278 | enum=MailingListAutoSubscribePolicy, |
279 | default=MailingListAutoSubscribePolicy.ON_REGISTRATION) |
280 | |
281 | merged = ForeignKey(dbName='merged', foreignKey='Person', default=None) |
282 | |
283 | datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW) |
284 | - creation_rationale = EnumCol(enum=PersonCreationRationale, default=None) |
285 | + creation_rationale = DBEnum(enum=PersonCreationRationale, default=None) |
286 | creation_comment = StringCol(default=None) |
287 | registrant = ForeignKey( |
288 | dbName='registrant', foreignKey='Person', default=None, |
289 | @@ -626,12 +626,13 @@ class Person( |
290 | _ircnicknames = SQLMultipleJoin('IrcID', joinColumn='person') |
291 | jabberids = SQLMultipleJoin('JabberID', joinColumn='person') |
292 | |
293 | - visibility = EnumCol( |
294 | + visibility = DBEnum( |
295 | enum=PersonVisibility, default=PersonVisibility.PUBLIC, |
296 | - storm_validator=validate_person_visibility) |
297 | + validator=validate_person_visibility) |
298 | |
299 | - personal_standing = EnumCol( |
300 | - enum=PersonalStanding, default=PersonalStanding.UNKNOWN, notNull=True) |
301 | + personal_standing = DBEnum( |
302 | + enum=PersonalStanding, default=PersonalStanding.UNKNOWN, |
303 | + allow_none=False) |
304 | |
305 | personal_standing_reason = StringCol(default=None) |
306 | |
307 | @@ -4316,7 +4317,7 @@ class SSHKey(SQLBase): |
308 | _table = 'SSHKey' |
309 | |
310 | person = ForeignKey(foreignKey='Person', dbName='person', notNull=True) |
311 | - keytype = EnumCol(dbName='keytype', notNull=True, enum=SSHKeyType) |
312 | + keytype = DBEnum(name='keytype', allow_none=False, enum=SSHKeyType) |
313 | keytext = StringCol(dbName='keytext', notNull=True) |
314 | comment = StringCol(dbName='comment', notNull=True) |
315 | |
316 | diff --git a/lib/lp/registry/model/persontransferjob.py b/lib/lp/registry/model/persontransferjob.py |
317 | index 75d7b56..69e44ac 100644 |
318 | --- a/lib/lp/registry/model/persontransferjob.py |
319 | +++ b/lib/lp/registry/model/persontransferjob.py |
320 | @@ -66,7 +66,7 @@ from lp.registry.personmerge import merge_people |
321 | from lp.registry.scripts.closeaccount import close_account |
322 | from lp.services.config import config |
323 | from lp.services.database.decoratedresultset import DecoratedResultSet |
324 | -from lp.services.database.enumcol import EnumCol |
325 | +from lp.services.database.enumcol import DBEnum |
326 | from lp.services.database.interfaces import ( |
327 | IMasterStore, |
328 | IStore, |
329 | @@ -98,7 +98,7 @@ class PersonTransferJob(StormBase): |
330 | minor_person_id = Int(name='minor_person') |
331 | minor_person = Reference(minor_person_id, Person.id) |
332 | |
333 | - job_type = EnumCol(enum=PersonTransferJobType, notNull=True) |
334 | + job_type = DBEnum(enum=PersonTransferJobType, allow_none=False) |
335 | |
336 | _json_data = Unicode('json_data') |
337 | |
338 | diff --git a/lib/lp/registry/model/product.py b/lib/lp/registry/model/product.py |
339 | index 5956904..471b997 100644 |
340 | --- a/lib/lp/registry/model/product.py |
341 | +++ b/lib/lp/registry/model/product.py |
342 | @@ -179,7 +179,7 @@ from lp.services.database import bulk |
343 | from lp.services.database.constants import UTC_NOW |
344 | from lp.services.database.datetimecol import UtcDateTimeCol |
345 | from lp.services.database.decoratedresultset import DecoratedResultSet |
346 | -from lp.services.database.enumcol import EnumCol |
347 | +from lp.services.database.enumcol import DBEnum |
348 | from lp.services.database.interfaces import IStore |
349 | from lp.services.database.sqlbase import ( |
350 | SQLBase, |
351 | @@ -346,9 +346,9 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements, |
352 | translationgroup = ForeignKey( |
353 | dbName='translationgroup', foreignKey='TranslationGroup', |
354 | notNull=False, default=None) |
355 | - translationpermission = EnumCol( |
356 | - dbName='translationpermission', notNull=True, |
357 | - schema=TranslationPermission, default=TranslationPermission.OPEN) |
358 | + translationpermission = DBEnum( |
359 | + name='translationpermission', allow_none=False, |
360 | + enum=TranslationPermission, default=TranslationPermission.OPEN) |
361 | translation_focus = ForeignKey( |
362 | dbName='translation_focus', foreignKey='ProductSeries', |
363 | notNull=False, default=None) |
364 | @@ -363,7 +363,7 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements, |
365 | dbName='official_malone', notNull=True, default=False) |
366 | remote_product = Unicode( |
367 | name='remote_product', allow_none=True, default=None) |
368 | - vcs = EnumCol(enum=VCSType, notNull=False) |
369 | + vcs = DBEnum(enum=VCSType, allow_none=True) |
370 | |
371 | # Cache of AccessPolicy.ids that convey launchpad.LimitedView. |
372 | # Unlike artifacts' cached access_policies, an AccessArtifactGrant |
373 | @@ -498,10 +498,9 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements, |
374 | yield CannotChangeInformationType( |
375 | 'Bug supervisor has inclusive membership.') |
376 | |
377 | - _information_type = EnumCol( |
378 | + _information_type = DBEnum( |
379 | enum=InformationType, default=InformationType.PUBLIC, |
380 | - dbName="information_type", |
381 | - storm_validator=_valid_product_information_type) |
382 | + name="information_type", validator=_valid_product_information_type) |
383 | |
384 | def _get_information_type(self): |
385 | return self._information_type or InformationType.PUBLIC |
386 | @@ -554,14 +553,12 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements, |
387 | self.official_blueprints, self.official_answers, |
388 | self.official_codehosting) |
389 | |
390 | - _answers_usage = EnumCol( |
391 | - dbName="answers_usage", notNull=True, |
392 | - schema=ServiceUsage, |
393 | - default=ServiceUsage.UNKNOWN) |
394 | - _blueprints_usage = EnumCol( |
395 | - dbName="blueprints_usage", notNull=True, |
396 | - schema=ServiceUsage, |
397 | - default=ServiceUsage.UNKNOWN) |
398 | + _answers_usage = DBEnum( |
399 | + name="answers_usage", allow_none=False, |
400 | + enum=ServiceUsage, default=ServiceUsage.UNKNOWN) |
401 | + _blueprints_usage = DBEnum( |
402 | + name="blueprints_usage", allow_none=False, |
403 | + enum=ServiceUsage, default=ServiceUsage.UNKNOWN) |
404 | |
405 | def validate_translations_usage(self, attr, value): |
406 | if value == ServiceUsage.LAUNCHPAD and self.private: |
407 | @@ -569,11 +566,10 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements, |
408 | "Translations are not supported for proprietary products.") |
409 | return value |
410 | |
411 | - translations_usage = EnumCol( |
412 | - dbName="translations_usage", notNull=True, |
413 | - schema=ServiceUsage, |
414 | - default=ServiceUsage.UNKNOWN, |
415 | - storm_validator=validate_translations_usage) |
416 | + translations_usage = DBEnum( |
417 | + name="translations_usage", allow_none=False, |
418 | + enum=ServiceUsage, default=ServiceUsage.UNKNOWN, |
419 | + validator=validate_translations_usage) |
420 | |
421 | @property |
422 | def codehosting_usage(self): |
423 | @@ -620,12 +616,12 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements, |
424 | project_reviewed = BoolCol(dbName='reviewed', notNull=True, default=False) |
425 | reviewer_whiteboard = StringCol(notNull=False, default=None) |
426 | private_bugs = False |
427 | - bug_sharing_policy = EnumCol( |
428 | - enum=BugSharingPolicy, notNull=False, default=None) |
429 | - branch_sharing_policy = EnumCol( |
430 | - enum=BranchSharingPolicy, notNull=False, default=None) |
431 | - specification_sharing_policy = EnumCol( |
432 | - enum=SpecificationSharingPolicy, notNull=False, |
433 | + bug_sharing_policy = DBEnum( |
434 | + enum=BugSharingPolicy, allow_none=True, default=None) |
435 | + branch_sharing_policy = DBEnum( |
436 | + enum=BranchSharingPolicy, allow_none=True, default=None) |
437 | + specification_sharing_policy = DBEnum( |
438 | + enum=SpecificationSharingPolicy, allow_none=True, |
439 | default=SpecificationSharingPolicy.PUBLIC) |
440 | autoupdate = BoolCol(dbName='autoupdate', notNull=True, default=False) |
441 | freshmeatproject = None |
442 | diff --git a/lib/lp/registry/model/productjob.py b/lib/lp/registry/model/productjob.py |
443 | index a24eccc..6aceb0b 100644 |
444 | --- a/lib/lp/registry/model/productjob.py |
445 | +++ b/lib/lp/registry/model/productjob.py |
446 | @@ -64,7 +64,7 @@ from lp.registry.model.commercialsubscription import CommercialSubscription |
447 | from lp.registry.model.product import Product |
448 | from lp.services.config import config |
449 | from lp.services.database.decoratedresultset import DecoratedResultSet |
450 | -from lp.services.database.enumcol import EnumCol |
451 | +from lp.services.database.enumcol import DBEnum |
452 | from lp.services.database.interfaces import ( |
453 | IMasterStore, |
454 | IStore, |
455 | @@ -136,7 +136,7 @@ class ProductJob(StormBase): |
456 | product_id = Int(name='product') |
457 | product = Reference(product_id, Product.id) |
458 | |
459 | - job_type = EnumCol(enum=ProductJobType, notNull=True) |
460 | + job_type = DBEnum(enum=ProductJobType, allow_none=False) |
461 | |
462 | _json_data = Unicode('json_data') |
463 | |
464 | diff --git a/lib/lp/registry/model/productlicense.py b/lib/lp/registry/model/productlicense.py |
465 | index 726808d..3b14c4a 100644 |
466 | --- a/lib/lp/registry/model/productlicense.py |
467 | +++ b/lib/lp/registry/model/productlicense.py |
468 | @@ -12,7 +12,7 @@ from zope.interface import implementer |
469 | |
470 | from lp.registry.interfaces.product import License |
471 | from lp.registry.interfaces.productlicense import IProductLicense |
472 | -from lp.services.database.enumcol import EnumCol |
473 | +from lp.services.database.enumcol import DBEnum |
474 | from lp.services.database.sqlbase import SQLBase |
475 | from lp.services.database.sqlobject import ForeignKey |
476 | |
477 | @@ -22,4 +22,4 @@ class ProductLicense(SQLBase): |
478 | """A product's licence.""" |
479 | |
480 | product = ForeignKey(dbName='product', foreignKey='Product', notNull=True) |
481 | - license = EnumCol(dbName='license', notNull=True, schema=License) |
482 | + license = DBEnum(name='license', allow_none=False, enum=License) |
483 | diff --git a/lib/lp/registry/model/productrelease.py b/lib/lp/registry/model/productrelease.py |
484 | index 14394c5..3b88d33 100644 |
485 | --- a/lib/lp/registry/model/productrelease.py |
486 | +++ b/lib/lp/registry/model/productrelease.py |
487 | @@ -40,7 +40,7 @@ from lp.registry.interfaces.productrelease import ( |
488 | ) |
489 | from lp.services.database.constants import UTC_NOW |
490 | from lp.services.database.datetimecol import UtcDateTimeCol |
491 | -from lp.services.database.enumcol import EnumCol |
492 | +from lp.services.database.enumcol import DBEnum |
493 | from lp.services.database.interfaces import IStore |
494 | from lp.services.database.sqlbase import ( |
495 | SQLBase, |
496 | @@ -227,8 +227,8 @@ class ProductReleaseFile(SQLBase): |
497 | signature = ForeignKey(dbName='signature', |
498 | foreignKey='LibraryFileAlias') |
499 | |
500 | - filetype = EnumCol(dbName='filetype', enum=UpstreamFileType, |
501 | - notNull=True, default=UpstreamFileType.CODETARBALL) |
502 | + filetype = DBEnum(name='filetype', enum=UpstreamFileType, |
503 | + allow_none=False, default=UpstreamFileType.CODETARBALL) |
504 | |
505 | description = StringCol(notNull=False, default=None) |
506 | |
507 | diff --git a/lib/lp/registry/model/productseries.py b/lib/lp/registry/model/productseries.py |
508 | index 4cfbda8..cf28a82 100644 |
509 | --- a/lib/lp/registry/model/productseries.py |
510 | +++ b/lib/lp/registry/model/productseries.py |
511 | @@ -63,7 +63,7 @@ from lp.registry.model.series import SeriesMixin |
512 | from lp.services.database.constants import UTC_NOW |
513 | from lp.services.database.datetimecol import UtcDateTimeCol |
514 | from lp.services.database.decoratedresultset import DecoratedResultSet |
515 | -from lp.services.database.enumcol import EnumCol |
516 | +from lp.services.database.enumcol import DBEnum |
517 | from lp.services.database.interfaces import IStore |
518 | from lp.services.database.sqlbase import SQLBase |
519 | from lp.services.database.sqlobject import ( |
520 | @@ -118,8 +118,8 @@ class ProductSeries(SQLBase, BugTargetBase, HasMilestonesMixin, |
521 | _table = 'ProductSeries' |
522 | |
523 | product = ForeignKey(dbName='product', foreignKey='Product', notNull=True) |
524 | - status = EnumCol( |
525 | - notNull=True, schema=SeriesStatus, |
526 | + status = DBEnum( |
527 | + allow_none=False, enum=SeriesStatus, |
528 | default=SeriesStatus.DEVELOPMENT) |
529 | name = StringCol(notNull=True) |
530 | datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW) |
531 | @@ -145,12 +145,12 @@ class ProductSeries(SQLBase, BugTargetBase, HasMilestonesMixin, |
532 | ' proprietary projects.') |
533 | return value |
534 | |
535 | - translations_autoimport_mode = EnumCol( |
536 | - dbName='translations_autoimport_mode', |
537 | - notNull=True, |
538 | - schema=TranslationsBranchImportMode, |
539 | + translations_autoimport_mode = DBEnum( |
540 | + name='translations_autoimport_mode', |
541 | + allow_none=False, |
542 | + enum=TranslationsBranchImportMode, |
543 | default=TranslationsBranchImportMode.NO_IMPORT, |
544 | - storm_validator=validate_autoimport_mode) |
545 | + validator=validate_autoimport_mode) |
546 | translations_branch = ForeignKey( |
547 | dbName='translations_branch', foreignKey='Branch', notNull=False, |
548 | default=None) |
549 | diff --git a/lib/lp/registry/model/projectgroup.py b/lib/lp/registry/model/projectgroup.py |
550 | index ad1b010..421692e 100644 |
551 | --- a/lib/lp/registry/model/projectgroup.py |
552 | +++ b/lib/lp/registry/model/projectgroup.py |
553 | @@ -87,7 +87,7 @@ from lp.registry.model.product import ( |
554 | from lp.registry.model.productseries import ProductSeries |
555 | from lp.services.database.constants import UTC_NOW |
556 | from lp.services.database.datetimecol import UtcDateTimeCol |
557 | -from lp.services.database.enumcol import EnumCol |
558 | +from lp.services.database.enumcol import DBEnum |
559 | from lp.services.database.interfaces import IStore |
560 | from lp.services.database.sqlbase import ( |
561 | SQLBase, |
562 | @@ -156,8 +156,9 @@ class ProjectGroup(SQLBase, BugTargetBase, HasSpecificationsMixin, |
563 | lastdoap = StringCol(dbName='lastdoap', notNull=False, default=None) |
564 | translationgroup = ForeignKey(dbName='translationgroup', |
565 | foreignKey='TranslationGroup', notNull=False, default=None) |
566 | - translationpermission = EnumCol(dbName='translationpermission', |
567 | - notNull=True, schema=TranslationPermission, |
568 | + translationpermission = DBEnum( |
569 | + name='translationpermission', |
570 | + allow_none=False, enum=TranslationPermission, |
571 | default=TranslationPermission.OPEN) |
572 | active = BoolCol(dbName='active', notNull=True, default=True) |
573 | reviewed = BoolCol(dbName='reviewed', notNull=True, default=False) |
574 | diff --git a/lib/lp/registry/model/sharingjob.py b/lib/lp/registry/model/sharingjob.py |
575 | index 10fe2e3..66eea40 100644 |
576 | --- a/lib/lp/registry/model/sharingjob.py |
577 | +++ b/lib/lp/registry/model/sharingjob.py |
578 | @@ -85,7 +85,7 @@ from lp.registry.model.person import Person |
579 | from lp.registry.model.product import Product |
580 | from lp.registry.model.teammembership import TeamParticipation |
581 | from lp.services.config import config |
582 | -from lp.services.database.enumcol import EnumCol |
583 | +from lp.services.database.enumcol import DBEnum |
584 | from lp.services.database.interfaces import IStore |
585 | from lp.services.database.sqlobject import SQLObjectNotFound |
586 | from lp.services.database.stormbase import StormBase |
587 | @@ -144,7 +144,7 @@ class SharingJob(StormBase): |
588 | grantee_id = Int(name='grantee') |
589 | grantee = Reference(grantee_id, Person.id) |
590 | |
591 | - job_type = EnumCol(enum=SharingJobType, notNull=True) |
592 | + job_type = DBEnum(enum=SharingJobType, allow_none=False) |
593 | |
594 | _json_data = Unicode('json_data') |
595 | |
596 | diff --git a/lib/lp/registry/model/teammembership.py b/lib/lp/registry/model/teammembership.py |
597 | index 3d5f53f..ab4c4cb 100644 |
598 | --- a/lib/lp/registry/model/teammembership.py |
599 | +++ b/lib/lp/registry/model/teammembership.py |
600 | @@ -49,7 +49,7 @@ from lp.registry.interfaces.teammembership import ( |
601 | ) |
602 | from lp.services.database.constants import UTC_NOW |
603 | from lp.services.database.datetimecol import UtcDateTimeCol |
604 | -from lp.services.database.enumcol import EnumCol |
605 | +from lp.services.database.enumcol import DBEnum |
606 | from lp.services.database.interfaces import IStore |
607 | from lp.services.database.sqlbase import ( |
608 | cursor, |
609 | @@ -86,8 +86,8 @@ class TeamMembership(SQLBase): |
610 | reviewed_by = ForeignKey( |
611 | dbName='reviewed_by', foreignKey='Person', |
612 | storm_validator=validate_public_person, default=None) |
613 | - status = EnumCol( |
614 | - dbName='status', notNull=True, enum=TeamMembershipStatus) |
615 | + status = DBEnum( |
616 | + name='status', allow_none=False, enum=TeamMembershipStatus) |
617 | # XXX: salgado, 2008-03-06: Need to rename datejoined and dateexpires to |
618 | # match their db names. |
619 | datejoined = UtcDateTimeCol(dbName='date_joined', default=None) |
LGTM