← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~mwhudson/launchpad/move-blueprint-vocabularies into lp:launchpad/devel

 

Michael Hudson-Doyle has proposed merging lp:~mwhudson/launchpad/move-blueprint-vocabularies into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


Hi,

This small branch moves the remaining blueprint vocabularies into the lp.blueprints tree.  There don't seem to be any direct tests to move :/

I made a small trivial change to stop the SpecificationDependenciesVocabulary using the LaunchBag.  The SpecificationVocabulary still does, it seems a bit more fiddly to replace so I didn't.

Also, two small flake fixes I couldn't resist.

Cheers,
mwh
-- 
https://code.launchpad.net/~mwhudson/launchpad/move-blueprint-vocabularies/+merge/36673
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mwhudson/launchpad/move-blueprint-vocabularies into lp:launchpad/devel.
=== modified file 'lib/canonical/launchpad/vocabularies/configure.zcml'
--- lib/canonical/launchpad/vocabularies/configure.zcml	2010-09-20 00:20:42 +0000
+++ lib/canonical/launchpad/vocabularies/configure.zcml	2010-09-26 22:54:42 +0000
@@ -172,19 +172,6 @@
 
 
   <securedutility
-    name="FutureSprint"
-    component="canonical.launchpad.vocabularies.FutureSprintVocabulary"
-    provides="zope.schema.interfaces.IVocabularyFactory"
-    >
-    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
-  </securedutility>
-
-  <class class="canonical.launchpad.vocabularies.FutureSprintVocabulary">
-    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
-  </class>
-
-
-  <securedutility
     name="Language"
     component="canonical.launchpad.vocabularies.LanguageVocabulary"
     provides="zope.schema.interfaces.IVocabularyFactory"
@@ -244,45 +231,6 @@
     <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
   </securedutility>
 
-
-  <securedutility
-    name="Specification"
-    component="canonical.launchpad.vocabularies.SpecificationVocabulary"
-    provides="zope.schema.interfaces.IVocabularyFactory"
-    >
-    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
-  </securedutility>
-
-  <class class="canonical.launchpad.vocabularies.SpecificationVocabulary">
-    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
-  </class>
-
-
-  <securedutility
-    name="SpecificationDependencies"
-    component="canonical.launchpad.vocabularies.SpecificationDependenciesVocabulary"
-    provides="zope.schema.interfaces.IVocabularyFactory"
-    >
-    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
-  </securedutility>
-
-  <class class="canonical.launchpad.vocabularies.SpecificationDependenciesVocabulary">
-    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
-  </class>
-
-  <securedutility
-    name="Sprint"
-    component="canonical.launchpad.vocabularies.SprintVocabulary"
-    provides="zope.schema.interfaces.IVocabularyFactory"
-    >
-    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
-  </securedutility>
-
-  <class class="canonical.launchpad.vocabularies.SprintVocabulary">
-    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
-  </class>
-
-
   <securedutility
     name="TranslationGroup"
     component="canonical.launchpad.vocabularies.TranslationGroupVocabulary"

=== modified file 'lib/canonical/launchpad/vocabularies/dbobjects.py'
--- lib/canonical/launchpad/vocabularies/dbobjects.py	2010-09-20 00:20:42 +0000
+++ lib/canonical/launchpad/vocabularies/dbobjects.py	2010-09-26 22:54:42 +0000
@@ -23,16 +23,12 @@
     'FilteredDistroArchSeriesVocabulary',
     'FilteredFullLanguagePackVocabulary',
     'FilteredLanguagePackVocabulary',
-    'FutureSprintVocabulary',
     'LanguageVocabulary',
     'PackageReleaseVocabulary',
     'PPAVocabulary',
     'ProcessorFamilyVocabulary',
     'ProcessorVocabulary',
     'project_products_using_malone_vocabulary_factory',
-    'SpecificationDependenciesVocabulary',
-    'SpecificationVocabulary',
-    'SprintVocabulary',
     'TranslatableLanguageVocabulary',
     'TranslationGroupVocabulary',
     'TranslationMessageVocabulary',
@@ -83,8 +79,6 @@
     )
 from lp.app.browser.stringformatter import FormattersAPI
 from lp.app.enums import ServiceUsage
-from lp.blueprints.model.specification import Specification
-from lp.blueprints.model.sprint import Sprint
 from lp.bugs.interfaces.bugtask import IBugTask
 from lp.bugs.interfaces.bugtracker import BugTrackerType
 from lp.bugs.model.bug import Bug
@@ -343,73 +337,6 @@
                 yield self.toTerm(distroarchseries)
 
 
-class FutureSprintVocabulary(NamedSQLObjectVocabulary):
-    """A vocab of all sprints that have not yet finished."""
-
-    _table = Sprint
-
-    def __iter__(self):
-        future_sprints = Sprint.select("time_ends > 'NOW'")
-        for sprint in future_sprints:
-            yield(self.toTerm(sprint))
-
-
-class SpecificationVocabulary(NamedSQLObjectVocabulary):
-    """List specifications for the current product or distribution in
-    ILaunchBag, EXCEPT for the current spec in LaunchBag if one exists.
-    """
-
-    _table = Specification
-    _orderBy = 'title'
-
-    def __iter__(self):
-        launchbag = getUtility(ILaunchBag)
-        target = None
-        product = launchbag.product
-        if product is not None:
-            target = product
-
-        distribution = launchbag.distribution
-        if distribution is not None:
-            target = distribution
-
-        if target is not None:
-            for spec in sorted(
-                target.specifications(), key=attrgetter('title')):
-                # we will not show the current specification in the
-                # launchbag
-                if spec == launchbag.specification:
-                    continue
-                # we will not show a specification that is blocked on the
-                # current specification in the launchbag. this is because
-                # the widget is currently used to select new dependencies,
-                # and we do not want to introduce circular dependencies.
-                if launchbag.specification is not None:
-                    if spec in launchbag.specification.all_blocked:
-                        continue
-                yield SimpleTerm(spec, spec.name, spec.title)
-
-
-class SpecificationDependenciesVocabulary(NamedSQLObjectVocabulary):
-    """List specifications on which the current specification depends."""
-
-    _table = Specification
-    _orderBy = 'title'
-
-    def __iter__(self):
-        launchbag = getUtility(ILaunchBag)
-        curr_spec = launchbag.specification
-
-        if curr_spec is not None:
-            for spec in sorted(
-                curr_spec.dependencies, key=attrgetter('title')):
-                yield SimpleTerm(spec, spec.name, spec.title)
-
-
-class SprintVocabulary(NamedSQLObjectVocabulary):
-    _table = Sprint
-
-
 class BugWatchVocabulary(SQLObjectVocabularyBase):
     _table = BugWatch
 

=== modified file 'lib/lp/blueprints/browser/specificationbranch.py'
--- lib/lp/blueprints/browser/specificationbranch.py	2010-08-20 20:31:18 +0000
+++ lib/lp/blueprints/browser/specificationbranch.py	2010-09-26 22:54:42 +0000
@@ -121,5 +121,4 @@
     @action(_('Continue'), name='continue')
     def continue_action(self, action, data):
         spec = data['specification']
-        spec_branch = spec.linkBranch(
-            branch=self.context, registrant=self.user)
+        spec.linkBranch(branch=self.context, registrant=self.user)

=== modified file 'lib/lp/blueprints/interfaces/specificationbranch.py'
--- lib/lp/blueprints/interfaces/specificationbranch.py	2010-08-20 20:31:18 +0000
+++ lib/lp/blueprints/interfaces/specificationbranch.py	2010-09-26 22:54:42 +0000
@@ -30,7 +30,6 @@
 from lp.blueprints.interfaces.specification import ISpecification
 from lp.code.interfaces.branch import IBranch
 from lp.registry.interfaces.person import IPerson
-from lp.services.fields import Summary
 
 
 class ISpecificationBranch(IHasDateCreated):

=== modified file 'lib/lp/blueprints/vocabularies/configure.zcml'
--- lib/lp/blueprints/vocabularies/configure.zcml	2010-08-25 06:28:51 +0000
+++ lib/lp/blueprints/vocabularies/configure.zcml	2010-09-26 22:54:42 +0000
@@ -16,4 +16,52 @@
     <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
   </class>
 
+  <securedutility
+    name="Specification"
+    component=".specification.SpecificationVocabulary"
+    provides="zope.schema.interfaces.IVocabularyFactory"
+    >
+    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
+  </securedutility>
+
+  <class class=".specification.SpecificationVocabulary">
+    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
+  </class>
+
+  <securedutility
+    name="SpecificationDependencies"
+    component=".specificationdependency.SpecificationDependenciesVocabulary"
+    provides="zope.schema.interfaces.IVocabularyFactory"
+    >
+    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
+  </securedutility>
+
+  <class class=".specificationdependency.SpecificationDependenciesVocabulary">
+    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
+  </class>
+
+  <securedutility
+    name="Sprint"
+    component=".sprint.SprintVocabulary"
+    provides="zope.schema.interfaces.IVocabularyFactory"
+    >
+    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
+  </securedutility>
+
+  <securedutility
+    name="FutureSprint"
+    component=".sprint.FutureSprintVocabulary"
+    provides="zope.schema.interfaces.IVocabularyFactory"
+    >
+    <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
+  </securedutility>
+
+  <class class=".sprint.FutureSprintVocabulary">
+    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
+  </class>
+
+  <class class=".sprint.SprintVocabulary">
+    <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
+  </class>
+
 </configure>

=== added file 'lib/lp/blueprints/vocabularies/specification.py'
--- lib/lp/blueprints/vocabularies/specification.py	1970-01-01 00:00:00 +0000
+++ lib/lp/blueprints/vocabularies/specification.py	2010-09-26 22:54:42 +0000
@@ -0,0 +1,55 @@
+# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""The vocabularies relating to specifications."""
+
+__metaclass__ = type
+__all__ = [
+    'SpecificationVocabulary',
+    ]
+
+from operator import attrgetter
+
+from zope.component import getUtility
+from zope.schema.vocabulary import SimpleTerm
+
+from canonical.launchpad.webapp.interfaces import ILaunchBag
+from canonical.launchpad.webapp.vocabulary import NamedSQLObjectVocabulary
+
+from lp.blueprints.model.specification import Specification
+
+
+class SpecificationVocabulary(NamedSQLObjectVocabulary):
+    """List specifications for the current product or distribution in
+    ILaunchBag, EXCEPT for the current spec in LaunchBag if one exists.
+    """
+
+    _table = Specification
+    _orderBy = 'title'
+
+    def __iter__(self):
+        launchbag = getUtility(ILaunchBag)
+        target = None
+        product = launchbag.product
+        if product is not None:
+            target = product
+
+        distribution = launchbag.distribution
+        if distribution is not None:
+            target = distribution
+
+        if target is not None:
+            for spec in sorted(
+                target.specifications(), key=attrgetter('title')):
+                # we will not show the current specification in the
+                # launchbag
+                if spec == launchbag.specification:
+                    continue
+                # we will not show a specification that is blocked on the
+                # current specification in the launchbag. this is because
+                # the widget is currently used to select new dependencies,
+                # and we do not want to introduce circular dependencies.
+                if launchbag.specification is not None:
+                    if spec in launchbag.specification.all_blocked:
+                        continue
+                yield SimpleTerm(spec, spec.name, spec.title)

=== modified file 'lib/lp/blueprints/vocabularies/specificationdependency.py'
--- lib/lp/blueprints/vocabularies/specificationdependency.py	2010-08-27 04:35:55 +0000
+++ lib/lp/blueprints/vocabularies/specificationdependency.py	2010-09-26 22:54:42 +0000
@@ -4,7 +4,12 @@
 """The vocabularies relating to dependencies of specifications."""
 
 __metaclass__ = type
-__all__ = ['SpecificationDepCandidatesVocabulary']
+__all__ = [
+    'SpecificationDepCandidatesVocabulary',
+    'SpecificationDependenciesVocabulary',
+    ]
+
+from operator import attrgetter
 
 from zope.component import getUtility
 from zope.interface import implements
@@ -19,6 +24,7 @@
 from canonical.launchpad.webapp.vocabulary import (
     CountableIterator,
     IHugeVocabulary,
+    NamedSQLObjectVocabulary,
     SQLObjectVocabularyBase,
     )
 
@@ -26,6 +32,7 @@
 from lp.blueprints.model.specification import Specification
 from lp.registry.interfaces.pillar import IPillarNameSet
 
+
 class SpecificationDepCandidatesVocabulary(SQLObjectVocabularyBase):
     """Specifications that could be dependencies of this spec.
 
@@ -158,3 +165,14 @@
     def __contains__(self, obj):
         return self._is_valid_candidate(obj)
 
+
+class SpecificationDependenciesVocabulary(NamedSQLObjectVocabulary):
+    """List specifications on which the current specification depends."""
+
+    _table = Specification
+    _orderBy = 'title'
+
+    def __iter__(self):
+        for spec in sorted(
+            self.context.dependencies, key=attrgetter('title')):
+            yield SimpleTerm(spec, spec.name, spec.title)

=== added file 'lib/lp/blueprints/vocabularies/sprint.py'
--- lib/lp/blueprints/vocabularies/sprint.py	1970-01-01 00:00:00 +0000
+++ lib/lp/blueprints/vocabularies/sprint.py	2010-09-26 22:54:42 +0000
@@ -0,0 +1,30 @@
+# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""The vocabularies relating to sprints."""
+
+__metaclass__ = type
+__all__ = [
+    'FutureSprintVocabulary',
+    'SprintVocabulary',
+    ]
+
+
+from canonical.launchpad.webapp.vocabulary import NamedSQLObjectVocabulary
+
+from lp.blueprints.model.sprint import Sprint
+
+
+class FutureSprintVocabulary(NamedSQLObjectVocabulary):
+    """A vocab of all sprints that have not yet finished."""
+
+    _table = Sprint
+
+    def __iter__(self):
+        future_sprints = Sprint.select("time_ends > 'NOW'")
+        for sprint in future_sprints:
+            yield(self.toTerm(sprint))
+
+
+class SprintVocabulary(NamedSQLObjectVocabulary):
+    _table = Sprint