← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/drop-garbo-accesspolicy into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/drop-garbo-accesspolicy into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/drop-garbo-accesspolicy/+merge/96285

Drop AccessPolicy{Distribution,Product}Addition. Thank them for their sterling work by removing them from the code base.
-- 
https://code.launchpad.net/~stevenk/launchpad/drop-garbo-accesspolicy/+merge/96285
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/drop-garbo-accesspolicy into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2012-03-05 03:49:22 +0000
+++ database/schema/security.cfg	2012-03-07 02:43:20 +0000
@@ -2132,7 +2132,6 @@
 
 [garbo]
 groups=script,read
-public.accesspolicy                     = SELECT, INSERT
 public.account                          = SELECT, DELETE
 public.answercontact                    = SELECT, DELETE
 public.branch                           = SELECT, UPDATE

=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2012-03-05 04:34:13 +0000
+++ lib/lp/scripts/garbo.py	2012-03-07 02:43:20 +0000
@@ -13,7 +13,6 @@
     datetime,
     timedelta,
     )
-import itertools
 import logging
 import multiprocessing
 import os
@@ -27,12 +26,7 @@
 import iso8601
 from psycopg2 import IntegrityError
 import pytz
-from storm.expr import (
-    Exists,
-    In,
-    Not,
-    Select,
-    )
+from storm.expr import In
 from storm.locals import (
     Max,
     Min,
@@ -63,12 +57,7 @@
     RevisionCache,
     )
 from lp.hardwaredb.model.hwdb import HWSubmission
-from lp.registry.enums import AccessPolicyType
-from lp.registry.interfaces.accesspolicy import IAccessPolicySource
-from lp.registry.model.accesspolicy import AccessPolicy
-from lp.registry.model.distribution import Distribution
 from lp.registry.model.person import Person
-from lp.registry.model.product import Product
 from lp.services.config import config
 from lp.services.database import postgresql
 from lp.services.database.constants import UTC_NOW
@@ -1001,64 +990,6 @@
         transaction.commit()
 
 
-class AccessPolicyDistributionAddition(TunableLoop):
-    """A `TunableLoop` to add AccessPolicy for all distributions."""
-
-    maximum_chunk_size = 5000
-
-    def __init__(self, log, abort_time=None):
-        super(AccessPolicyDistributionAddition, self).__init__(
-            log, abort_time)
-        self.transaction = transaction
-        self.store = IMasterStore(Distribution)
-
-    def findDistributions(self):
-        return self.store.find(
-            Distribution,
-            Not(Exists(
-                Select(AccessPolicy.id,
-                tables=[AccessPolicy], where=[
-                    AccessPolicy.distribution_id == Distribution.id]))))
-
-    def isDone(self):
-        return self.findDistributions().is_empty()
-
-    def __call__(self, chunk_size):
-        policies = itertools.product(
-            self.findDistributions()[:chunk_size],
-            (AccessPolicyType.USERDATA, AccessPolicyType.EMBARGOEDSECURITY))
-        getUtility(IAccessPolicySource).create(policies)
-        self.transaction.commit()
-
-
-class AccessPolicyProductAddition(TunableLoop):
-    """A `TunableLoop` to add AccessPolicy for all products."""
-
-    maximum_chunk_size = 5000
-
-    def __init__(self, log, abort_time=None):
-        super(AccessPolicyProductAddition, self).__init__(log, abort_time)
-        self.transaction = transaction
-        self.store = IMasterStore(Product)
-
-    def findProducts(self):
-        return self.store.find(
-            Product,
-            Not(Exists(
-                Select(AccessPolicy.id, tables=[AccessPolicy], where=[
-                    AccessPolicy.product_id == Product.id]))))
-
-    def isDone(self):
-        return self.findProducts().is_empty()
-
-    def __call__(self, chunk_size):
-        policies = itertools.product(
-            self.findProducts()[:chunk_size],
-            (AccessPolicyType.USERDATA, AccessPolicyType.EMBARGOEDSECURITY))
-        getUtility(IAccessPolicySource).create(policies)
-        self.transaction.commit()
-
-
 class SpecificationWorkitemMigrator(TunableLoop):
     """Migrate work-items from Specification.whiteboard to
     SpecificationWorkItem.
@@ -1384,8 +1315,6 @@
         UnusedSessionPruner,
         DuplicateSessionPruner,
         BugHeatUpdater,
-        AccessPolicyDistributionAddition,
-        AccessPolicyProductAddition,
         ]
     experimental_tunable_loops = []
 

=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py	2012-03-05 04:34:13 +0000
+++ lib/lp/scripts/tests/test_garbo.py	2012-03-07 02:43:20 +0000
@@ -54,8 +54,6 @@
     )
 from lp.code.model.codeimportevent import CodeImportEvent
 from lp.code.model.codeimportresult import CodeImportResult
-from lp.registry.enums import AccessPolicyType
-from lp.registry.interfaces.accesspolicy import IAccessPolicySource
 from lp.registry.interfaces.person import IPersonSet
 from lp.scripts.garbo import (
     AntiqueSessionPruner,
@@ -1021,26 +1019,6 @@
         self.runHourly()
         self.assertNotEqual(old_update, bug.heat_last_updated)
 
-    def test_AccessPolicyDistributionAddition(self):
-        switch_dbuser('testadmin')
-        distribution = self.factory.makeDistribution()
-        transaction.commit()
-        self.runHourly()
-        ap = getUtility(IAccessPolicySource).findByPillar((distribution,))
-        expected = [
-            AccessPolicyType.USERDATA, AccessPolicyType.EMBARGOEDSECURITY]
-        self.assertContentEqual(expected, [policy.type for policy in ap])
-
-    def test_AccessPolicyProductAddition(self):
-        switch_dbuser('testadmin')
-        product = self.factory.makeProduct()
-        transaction.commit()
-        self.runHourly()
-        ap = getUtility(IAccessPolicySource).findByPillar((product,))
-        expected = [
-            AccessPolicyType.USERDATA, AccessPolicyType.EMBARGOEDSECURITY]
-        self.assertContentEqual(expected, [policy.type for policy in ap])
-
     def test_SpecificationWorkitemMigrator_not_enabled_by_default(self):
         self.assertFalse(getFeatureFlag('garbo.workitem_migrator.enabled'))
         switch_dbuser('testadmin')