launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10549
[Merge] lp:~abentley/launchpad/blueprint-info-type-code into lp:launchpad
Aaron Bentley has proposed merging lp:~abentley/launchpad/blueprint-info-type-code into lp:launchpad with lp:~abentley/launchpad/blueprint-info-type-idx as a prerequisite.
Requested reviews:
Robert Collins (lifeless): db
Stuart Bishop (stub): db
For more details, see:
https://code.launchpad.net/~abentley/launchpad/blueprint-info-type-code/+merge/117981
= Summary =
Add model code and garbo job for Specification.information_type
Previous: https://code.launchpad.net/~abentley/launchpad/blueprint-info-type-idx/+merge/117980
== Pre-implementation notes ==
Advised by lifeless and wgrant
== LOC Rationale ==
Part of Private projects
== Implementation details ==
Since we can't set the information_type to PUBLIC when creating the column, we must do it afterward.
The model code comes in handy for doing this.
== Tests ==
bin/test -t test_SpecificationInformationTypeDefault
== Demo and Q/A ==
None
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
database/schema/patch-2209-28-1.sql
database/schema/comments.sql
database/schema/security.cfg
lib/lp/scripts/garbo.py
lib/lp/blueprints/model/specification.py
lib/lp/scripts/tests/test_garbo.py
database/schema/patch-2209-28-2.sql
lib/lp/blueprints/interfaces/specification.py
--
https://code.launchpad.net/~abentley/launchpad/blueprint-info-type-code/+merge/117981
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2012-08-01 05:29:38 +0000
+++ database/schema/security.cfg 2012-08-02 20:01:20 +0000
@@ -2257,6 +2257,7 @@
public.sourcepackagename = SELECT
public.sourcepackagerelease = SELECT
public.sourcepackagepublishinghistory = SELECT, UPDATE
+public.specification = SELECT, UPDATE
public.suggestivepotemplate = INSERT, DELETE
public.teamparticipation = SELECT, DELETE
public.translationmessage = SELECT, DELETE
=== modified file 'lib/lp/blueprints/interfaces/specification.py'
--- lib/lp/blueprints/interfaces/specification.py 2012-05-17 07:46:56 +0000
+++ lib/lp/blueprints/interfaces/specification.py 2012-08-02 20:01:20 +0000
@@ -70,6 +70,7 @@
from lp.blueprints.interfaces.sprint import ISprint
from lp.bugs.interfaces.buglink import IBugLinkTarget
from lp.code.interfaces.branchlink import IHasLinkedBranches
+from lp.registry.enums import InformationType
from lp.registry.interfaces.milestone import IMilestone
from lp.registry.interfaces.person import IPerson
from lp.registry.interfaces.projectgroup import IProjectGroup
@@ -152,6 +153,13 @@
id = Int(title=_("Database ID"), required=True, readonly=True)
+ information_type = exported(
+ Choice(
+ title=_('Information Type'), vocabulary=InformationType,
+ required=True, readonly=True, default=InformationType.PUBLIC,
+ description=_(
+ 'The type of information contained in this specification.')))
+
name = exported(
SpecNameField(
title=_('Name'), required=True, readonly=False,
=== modified file 'lib/lp/blueprints/model/specification.py'
--- lib/lp/blueprints/model/specification.py 2012-06-18 11:19:46 +0000
+++ lib/lp/blueprints/model/specification.py 2012-08-02 20:01:20 +0000
@@ -70,6 +70,7 @@
from lp.bugs.model.buglinktarget import BugLinkTargetMixin
from lp.registry.interfaces.distribution import IDistribution
from lp.registry.interfaces.distroseries import IDistroSeries
+from lp.registry.enums import InformationType
from lp.registry.interfaces.person import validate_public_person
from lp.registry.interfaces.product import IProduct
from lp.registry.interfaces.productseries import IProductSeries
@@ -123,6 +124,9 @@
_defaultOrder = ['-priority', 'definition_status', 'name', 'id']
# db field names
+
+ information_type = EnumCol(
+ enum=InformationType, default=InformationType.PUBLIC)
name = StringCol(unique=True, notNull=True)
title = StringCol(notNull=True)
summary = StringCol(notNull=True)
=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py 2012-07-23 11:25:26 +0000
+++ lib/lp/scripts/garbo.py 2012-08-02 20:01:20 +0000
@@ -26,7 +26,11 @@
import iso8601
from psycopg2 import IntegrityError
import pytz
-from storm.expr import In
+from storm.expr import (
+ In,
+ Select,
+ Update,
+ )
from storm.locals import (
Max,
Min,
@@ -38,6 +42,7 @@
from zope.security.proxy import removeSecurityProxy
from lp.answers.model.answercontact import AnswerContact
+from lp.blueprints.model.specification import Specification
from lp.bugs.interfaces.bug import IBugSet
from lp.bugs.model.bug import Bug
from lp.bugs.model.bugattachment import BugAttachment
@@ -927,6 +932,32 @@
self.done = True
+class SpecificationInformationTypeDefault(TunableLoop):
+ """Set all Specification.information_type to Public (default)."""
+ maximum_chunk_size = 1000
+
+ def __init__(self, log, abort_time=None):
+ super(SpecificationInformationTypeDefault, self).__init__(log,
+ abort_time)
+ self.rows_updated = None
+ self.store = IMasterStore(Specification)
+
+ def isDone(self):
+ """See `TunableLoop`."""
+ return self.rows_updated == 0
+
+ def __call__(self, chunk_size):
+ """See `TunableLoop`."""
+ subselect = Select(
+ Specification.id, Specification.information_type == None,
+ limit=chunk_size)
+ result = self.store.execute(
+ Update({Specification.information_type: 1},
+ Specification.id.is_in(subselect)))
+ transaction.commit()
+ self.rows_updated = result.rowcount
+
+
class UnusedPOTMsgSetPruner(TunableLoop):
"""Cleans up unused POTMsgSets."""
@@ -1273,6 +1304,7 @@
OldTimeLimitedTokenDeleter,
RevisionAuthorEmailLinker,
ScrubPOFileTranslator,
+ SpecificationInformationTypeDefault,
SuggestiveTemplatesCacheUpdater,
POTranslationPruner,
UnusedPOTMsgSetPruner,
=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py 2012-07-23 11:25:26 +0000
+++ lib/lp/scripts/tests/test_garbo.py 2012-08-02 20:01:20 +0000
@@ -35,6 +35,7 @@
from zope.security.proxy import removeSecurityProxy
from lp.answers.model.answercontact import AnswerContact
+from lp.blueprints.model.specification import Specification
from lp.bugs.model.bugnotification import (
BugNotification,
BugNotificationRecipient,
@@ -620,6 +621,18 @@
"SELECT COUNT(*) FROM %s" % table_name).get_one()[0]
self.failUnless(num_unexpired > 0)
+ def test_SpecificationInformationTypeDefault(self):
+ switch_dbuser('testadmin')
+ spec = self.factory.makeSpecification()
+ removeSecurityProxy(spec).information_type = None
+ store = Store.of(spec)
+ store.flush()
+ self.assertEqual(1, store.find(Specification,
+ Specification.information_type == None).count())
+ self.runDaily()
+ self.assertEqual(0, store.find(Specification,
+ Specification.information_type == None).count())
+
def test_RevisionAuthorEmailLinker(self):
switch_dbuser('testadmin')
rev1 = self.factory.makeRevision('Author 1 <author-1@xxxxxxxxxxx>')
Follow ups