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

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 11636
Proposed branch: lp:~mwhudson/launchpad/move-blueprint-vocabularies
Merge into: lp:launchpad
Diff against target: 397 lines (+153/-129)
8 files modified
lib/canonical/launchpad/vocabularies/configure.zcml (+0/-52)
lib/canonical/launchpad/vocabularies/dbobjects.py (+0/-73)
lib/lp/blueprints/browser/specificationbranch.py (+1/-2)
lib/lp/blueprints/interfaces/specificationbranch.py (+0/-1)
lib/lp/blueprints/vocabularies/configure.zcml (+48/-0)
lib/lp/blueprints/vocabularies/specification.py (+55/-0)
lib/lp/blueprints/vocabularies/specificationdependency.py (+19/-1)
lib/lp/blueprints/vocabularies/sprint.py (+30/-0)
To merge this branch: bzr merge lp:~mwhudson/launchpad/move-blueprint-vocabularies
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+36673@code.launchpad.net

Commit message

Move the remaining blueprint vocabularies into the lp.blueprints tree

Description of the change

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

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
172172
173173
174 <securedutility174 <securedutility
175 name="FutureSprint"
176 component="canonical.launchpad.vocabularies.FutureSprintVocabulary"
177 provides="zope.schema.interfaces.IVocabularyFactory"
178 >
179 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
180 </securedutility>
181
182 <class class="canonical.launchpad.vocabularies.FutureSprintVocabulary">
183 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
184 </class>
185
186
187 <securedutility
188 name="Language"175 name="Language"
189 component="canonical.launchpad.vocabularies.LanguageVocabulary"176 component="canonical.launchpad.vocabularies.LanguageVocabulary"
190 provides="zope.schema.interfaces.IVocabularyFactory"177 provides="zope.schema.interfaces.IVocabularyFactory"
@@ -244,45 +231,6 @@
244 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>231 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
245 </securedutility>232 </securedutility>
246233
247
248 <securedutility
249 name="Specification"
250 component="canonical.launchpad.vocabularies.SpecificationVocabulary"
251 provides="zope.schema.interfaces.IVocabularyFactory"
252 >
253 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
254 </securedutility>
255
256 <class class="canonical.launchpad.vocabularies.SpecificationVocabulary">
257 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
258 </class>
259
260
261 <securedutility
262 name="SpecificationDependencies"
263 component="canonical.launchpad.vocabularies.SpecificationDependenciesVocabulary"
264 provides="zope.schema.interfaces.IVocabularyFactory"
265 >
266 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
267 </securedutility>
268
269 <class class="canonical.launchpad.vocabularies.SpecificationDependenciesVocabulary">
270 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
271 </class>
272
273 <securedutility
274 name="Sprint"
275 component="canonical.launchpad.vocabularies.SprintVocabulary"
276 provides="zope.schema.interfaces.IVocabularyFactory"
277 >
278 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
279 </securedutility>
280
281 <class class="canonical.launchpad.vocabularies.SprintVocabulary">
282 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
283 </class>
284
285
286 <securedutility234 <securedutility
287 name="TranslationGroup"235 name="TranslationGroup"
288 component="canonical.launchpad.vocabularies.TranslationGroupVocabulary"236 component="canonical.launchpad.vocabularies.TranslationGroupVocabulary"
289237
=== 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 @@
23 'FilteredDistroArchSeriesVocabulary',23 'FilteredDistroArchSeriesVocabulary',
24 'FilteredFullLanguagePackVocabulary',24 'FilteredFullLanguagePackVocabulary',
25 'FilteredLanguagePackVocabulary',25 'FilteredLanguagePackVocabulary',
26 'FutureSprintVocabulary',
27 'LanguageVocabulary',26 'LanguageVocabulary',
28 'PackageReleaseVocabulary',27 'PackageReleaseVocabulary',
29 'PPAVocabulary',28 'PPAVocabulary',
30 'ProcessorFamilyVocabulary',29 'ProcessorFamilyVocabulary',
31 'ProcessorVocabulary',30 'ProcessorVocabulary',
32 'project_products_using_malone_vocabulary_factory',31 'project_products_using_malone_vocabulary_factory',
33 'SpecificationDependenciesVocabulary',
34 'SpecificationVocabulary',
35 'SprintVocabulary',
36 'TranslatableLanguageVocabulary',32 'TranslatableLanguageVocabulary',
37 'TranslationGroupVocabulary',33 'TranslationGroupVocabulary',
38 'TranslationMessageVocabulary',34 'TranslationMessageVocabulary',
@@ -83,8 +79,6 @@
83 )79 )
84from lp.app.browser.stringformatter import FormattersAPI80from lp.app.browser.stringformatter import FormattersAPI
85from lp.app.enums import ServiceUsage81from lp.app.enums import ServiceUsage
86from lp.blueprints.model.specification import Specification
87from lp.blueprints.model.sprint import Sprint
88from lp.bugs.interfaces.bugtask import IBugTask82from lp.bugs.interfaces.bugtask import IBugTask
89from lp.bugs.interfaces.bugtracker import BugTrackerType83from lp.bugs.interfaces.bugtracker import BugTrackerType
90from lp.bugs.model.bug import Bug84from lp.bugs.model.bug import Bug
@@ -343,73 +337,6 @@
343 yield self.toTerm(distroarchseries)337 yield self.toTerm(distroarchseries)
344338
345339
346class FutureSprintVocabulary(NamedSQLObjectVocabulary):
347 """A vocab of all sprints that have not yet finished."""
348
349 _table = Sprint
350
351 def __iter__(self):
352 future_sprints = Sprint.select("time_ends > 'NOW'")
353 for sprint in future_sprints:
354 yield(self.toTerm(sprint))
355
356
357class SpecificationVocabulary(NamedSQLObjectVocabulary):
358 """List specifications for the current product or distribution in
359 ILaunchBag, EXCEPT for the current spec in LaunchBag if one exists.
360 """
361
362 _table = Specification
363 _orderBy = 'title'
364
365 def __iter__(self):
366 launchbag = getUtility(ILaunchBag)
367 target = None
368 product = launchbag.product
369 if product is not None:
370 target = product
371
372 distribution = launchbag.distribution
373 if distribution is not None:
374 target = distribution
375
376 if target is not None:
377 for spec in sorted(
378 target.specifications(), key=attrgetter('title')):
379 # we will not show the current specification in the
380 # launchbag
381 if spec == launchbag.specification:
382 continue
383 # we will not show a specification that is blocked on the
384 # current specification in the launchbag. this is because
385 # the widget is currently used to select new dependencies,
386 # and we do not want to introduce circular dependencies.
387 if launchbag.specification is not None:
388 if spec in launchbag.specification.all_blocked:
389 continue
390 yield SimpleTerm(spec, spec.name, spec.title)
391
392
393class SpecificationDependenciesVocabulary(NamedSQLObjectVocabulary):
394 """List specifications on which the current specification depends."""
395
396 _table = Specification
397 _orderBy = 'title'
398
399 def __iter__(self):
400 launchbag = getUtility(ILaunchBag)
401 curr_spec = launchbag.specification
402
403 if curr_spec is not None:
404 for spec in sorted(
405 curr_spec.dependencies, key=attrgetter('title')):
406 yield SimpleTerm(spec, spec.name, spec.title)
407
408
409class SprintVocabulary(NamedSQLObjectVocabulary):
410 _table = Sprint
411
412
413class BugWatchVocabulary(SQLObjectVocabularyBase):340class BugWatchVocabulary(SQLObjectVocabularyBase):
414 _table = BugWatch341 _table = BugWatch
415342
416343
=== 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 @@
121 @action(_('Continue'), name='continue')121 @action(_('Continue'), name='continue')
122 def continue_action(self, action, data):122 def continue_action(self, action, data):
123 spec = data['specification']123 spec = data['specification']
124 spec_branch = spec.linkBranch(124 spec.linkBranch(branch=self.context, registrant=self.user)
125 branch=self.context, registrant=self.user)
126125
=== 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 @@
30from lp.blueprints.interfaces.specification import ISpecification30from lp.blueprints.interfaces.specification import ISpecification
31from lp.code.interfaces.branch import IBranch31from lp.code.interfaces.branch import IBranch
32from lp.registry.interfaces.person import IPerson32from lp.registry.interfaces.person import IPerson
33from lp.services.fields import Summary
3433
3534
36class ISpecificationBranch(IHasDateCreated):35class ISpecificationBranch(IHasDateCreated):
3736
=== 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 @@
16 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>16 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
17 </class>17 </class>
1818
19 <securedutility
20 name="Specification"
21 component=".specification.SpecificationVocabulary"
22 provides="zope.schema.interfaces.IVocabularyFactory"
23 >
24 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
25 </securedutility>
26
27 <class class=".specification.SpecificationVocabulary">
28 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
29 </class>
30
31 <securedutility
32 name="SpecificationDependencies"
33 component=".specificationdependency.SpecificationDependenciesVocabulary"
34 provides="zope.schema.interfaces.IVocabularyFactory"
35 >
36 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
37 </securedutility>
38
39 <class class=".specificationdependency.SpecificationDependenciesVocabulary">
40 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
41 </class>
42
43 <securedutility
44 name="Sprint"
45 component=".sprint.SprintVocabulary"
46 provides="zope.schema.interfaces.IVocabularyFactory"
47 >
48 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
49 </securedutility>
50
51 <securedutility
52 name="FutureSprint"
53 component=".sprint.FutureSprintVocabulary"
54 provides="zope.schema.interfaces.IVocabularyFactory"
55 >
56 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
57 </securedutility>
58
59 <class class=".sprint.FutureSprintVocabulary">
60 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
61 </class>
62
63 <class class=".sprint.SprintVocabulary">
64 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
65 </class>
66
19</configure>67</configure>
2068
=== 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 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""The vocabularies relating to specifications."""
5
6__metaclass__ = type
7__all__ = [
8 'SpecificationVocabulary',
9 ]
10
11from operator import attrgetter
12
13from zope.component import getUtility
14from zope.schema.vocabulary import SimpleTerm
15
16from canonical.launchpad.webapp.interfaces import ILaunchBag
17from canonical.launchpad.webapp.vocabulary import NamedSQLObjectVocabulary
18
19from lp.blueprints.model.specification import Specification
20
21
22class SpecificationVocabulary(NamedSQLObjectVocabulary):
23 """List specifications for the current product or distribution in
24 ILaunchBag, EXCEPT for the current spec in LaunchBag if one exists.
25 """
26
27 _table = Specification
28 _orderBy = 'title'
29
30 def __iter__(self):
31 launchbag = getUtility(ILaunchBag)
32 target = None
33 product = launchbag.product
34 if product is not None:
35 target = product
36
37 distribution = launchbag.distribution
38 if distribution is not None:
39 target = distribution
40
41 if target is not None:
42 for spec in sorted(
43 target.specifications(), key=attrgetter('title')):
44 # we will not show the current specification in the
45 # launchbag
46 if spec == launchbag.specification:
47 continue
48 # we will not show a specification that is blocked on the
49 # current specification in the launchbag. this is because
50 # the widget is currently used to select new dependencies,
51 # and we do not want to introduce circular dependencies.
52 if launchbag.specification is not None:
53 if spec in launchbag.specification.all_blocked:
54 continue
55 yield SimpleTerm(spec, spec.name, spec.title)
056
=== 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 @@
4"""The vocabularies relating to dependencies of specifications."""4"""The vocabularies relating to dependencies of specifications."""
55
6__metaclass__ = type6__metaclass__ = type
7__all__ = ['SpecificationDepCandidatesVocabulary']7__all__ = [
8 'SpecificationDepCandidatesVocabulary',
9 'SpecificationDependenciesVocabulary',
10 ]
11
12from operator import attrgetter
813
9from zope.component import getUtility14from zope.component import getUtility
10from zope.interface import implements15from zope.interface import implements
@@ -19,6 +24,7 @@
19from canonical.launchpad.webapp.vocabulary import (24from canonical.launchpad.webapp.vocabulary import (
20 CountableIterator,25 CountableIterator,
21 IHugeVocabulary,26 IHugeVocabulary,
27 NamedSQLObjectVocabulary,
22 SQLObjectVocabularyBase,28 SQLObjectVocabularyBase,
23 )29 )
2430
@@ -26,6 +32,7 @@
26from lp.blueprints.model.specification import Specification32from lp.blueprints.model.specification import Specification
27from lp.registry.interfaces.pillar import IPillarNameSet33from lp.registry.interfaces.pillar import IPillarNameSet
2834
35
29class SpecificationDepCandidatesVocabulary(SQLObjectVocabularyBase):36class SpecificationDepCandidatesVocabulary(SQLObjectVocabularyBase):
30 """Specifications that could be dependencies of this spec.37 """Specifications that could be dependencies of this spec.
3138
@@ -158,3 +165,14 @@
158 def __contains__(self, obj):165 def __contains__(self, obj):
159 return self._is_valid_candidate(obj)166 return self._is_valid_candidate(obj)
160167
168
169class SpecificationDependenciesVocabulary(NamedSQLObjectVocabulary):
170 """List specifications on which the current specification depends."""
171
172 _table = Specification
173 _orderBy = 'title'
174
175 def __iter__(self):
176 for spec in sorted(
177 self.context.dependencies, key=attrgetter('title')):
178 yield SimpleTerm(spec, spec.name, spec.title)
161179
=== 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 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""The vocabularies relating to sprints."""
5
6__metaclass__ = type
7__all__ = [
8 'FutureSprintVocabulary',
9 'SprintVocabulary',
10 ]
11
12
13from canonical.launchpad.webapp.vocabulary import NamedSQLObjectVocabulary
14
15from lp.blueprints.model.sprint import Sprint
16
17
18class FutureSprintVocabulary(NamedSQLObjectVocabulary):
19 """A vocab of all sprints that have not yet finished."""
20
21 _table = Sprint
22
23 def __iter__(self):
24 future_sprints = Sprint.select("time_ends > 'NOW'")
25 for sprint in future_sprints:
26 yield(self.toTerm(sprint))
27
28
29class SprintVocabulary(NamedSQLObjectVocabulary):
30 _table = Sprint