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
1=== modified file 'lib/canonical/launchpad/vocabularies/configure.zcml'
2--- lib/canonical/launchpad/vocabularies/configure.zcml 2010-09-20 00:20:42 +0000
3+++ lib/canonical/launchpad/vocabularies/configure.zcml 2010-09-26 22:54:42 +0000
4@@ -172,19 +172,6 @@
5
6
7 <securedutility
8- name="FutureSprint"
9- component="canonical.launchpad.vocabularies.FutureSprintVocabulary"
10- provides="zope.schema.interfaces.IVocabularyFactory"
11- >
12- <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
13- </securedutility>
14-
15- <class class="canonical.launchpad.vocabularies.FutureSprintVocabulary">
16- <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
17- </class>
18-
19-
20- <securedutility
21 name="Language"
22 component="canonical.launchpad.vocabularies.LanguageVocabulary"
23 provides="zope.schema.interfaces.IVocabularyFactory"
24@@ -244,45 +231,6 @@
25 <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
26 </securedutility>
27
28-
29- <securedutility
30- name="Specification"
31- component="canonical.launchpad.vocabularies.SpecificationVocabulary"
32- provides="zope.schema.interfaces.IVocabularyFactory"
33- >
34- <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
35- </securedutility>
36-
37- <class class="canonical.launchpad.vocabularies.SpecificationVocabulary">
38- <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
39- </class>
40-
41-
42- <securedutility
43- name="SpecificationDependencies"
44- component="canonical.launchpad.vocabularies.SpecificationDependenciesVocabulary"
45- provides="zope.schema.interfaces.IVocabularyFactory"
46- >
47- <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
48- </securedutility>
49-
50- <class class="canonical.launchpad.vocabularies.SpecificationDependenciesVocabulary">
51- <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
52- </class>
53-
54- <securedutility
55- name="Sprint"
56- component="canonical.launchpad.vocabularies.SprintVocabulary"
57- provides="zope.schema.interfaces.IVocabularyFactory"
58- >
59- <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
60- </securedutility>
61-
62- <class class="canonical.launchpad.vocabularies.SprintVocabulary">
63- <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
64- </class>
65-
66-
67 <securedutility
68 name="TranslationGroup"
69 component="canonical.launchpad.vocabularies.TranslationGroupVocabulary"
70
71=== modified file 'lib/canonical/launchpad/vocabularies/dbobjects.py'
72--- lib/canonical/launchpad/vocabularies/dbobjects.py 2010-09-20 00:20:42 +0000
73+++ lib/canonical/launchpad/vocabularies/dbobjects.py 2010-09-26 22:54:42 +0000
74@@ -23,16 +23,12 @@
75 'FilteredDistroArchSeriesVocabulary',
76 'FilteredFullLanguagePackVocabulary',
77 'FilteredLanguagePackVocabulary',
78- 'FutureSprintVocabulary',
79 'LanguageVocabulary',
80 'PackageReleaseVocabulary',
81 'PPAVocabulary',
82 'ProcessorFamilyVocabulary',
83 'ProcessorVocabulary',
84 'project_products_using_malone_vocabulary_factory',
85- 'SpecificationDependenciesVocabulary',
86- 'SpecificationVocabulary',
87- 'SprintVocabulary',
88 'TranslatableLanguageVocabulary',
89 'TranslationGroupVocabulary',
90 'TranslationMessageVocabulary',
91@@ -83,8 +79,6 @@
92 )
93 from lp.app.browser.stringformatter import FormattersAPI
94 from lp.app.enums import ServiceUsage
95-from lp.blueprints.model.specification import Specification
96-from lp.blueprints.model.sprint import Sprint
97 from lp.bugs.interfaces.bugtask import IBugTask
98 from lp.bugs.interfaces.bugtracker import BugTrackerType
99 from lp.bugs.model.bug import Bug
100@@ -343,73 +337,6 @@
101 yield self.toTerm(distroarchseries)
102
103
104-class FutureSprintVocabulary(NamedSQLObjectVocabulary):
105- """A vocab of all sprints that have not yet finished."""
106-
107- _table = Sprint
108-
109- def __iter__(self):
110- future_sprints = Sprint.select("time_ends > 'NOW'")
111- for sprint in future_sprints:
112- yield(self.toTerm(sprint))
113-
114-
115-class SpecificationVocabulary(NamedSQLObjectVocabulary):
116- """List specifications for the current product or distribution in
117- ILaunchBag, EXCEPT for the current spec in LaunchBag if one exists.
118- """
119-
120- _table = Specification
121- _orderBy = 'title'
122-
123- def __iter__(self):
124- launchbag = getUtility(ILaunchBag)
125- target = None
126- product = launchbag.product
127- if product is not None:
128- target = product
129-
130- distribution = launchbag.distribution
131- if distribution is not None:
132- target = distribution
133-
134- if target is not None:
135- for spec in sorted(
136- target.specifications(), key=attrgetter('title')):
137- # we will not show the current specification in the
138- # launchbag
139- if spec == launchbag.specification:
140- continue
141- # we will not show a specification that is blocked on the
142- # current specification in the launchbag. this is because
143- # the widget is currently used to select new dependencies,
144- # and we do not want to introduce circular dependencies.
145- if launchbag.specification is not None:
146- if spec in launchbag.specification.all_blocked:
147- continue
148- yield SimpleTerm(spec, spec.name, spec.title)
149-
150-
151-class SpecificationDependenciesVocabulary(NamedSQLObjectVocabulary):
152- """List specifications on which the current specification depends."""
153-
154- _table = Specification
155- _orderBy = 'title'
156-
157- def __iter__(self):
158- launchbag = getUtility(ILaunchBag)
159- curr_spec = launchbag.specification
160-
161- if curr_spec is not None:
162- for spec in sorted(
163- curr_spec.dependencies, key=attrgetter('title')):
164- yield SimpleTerm(spec, spec.name, spec.title)
165-
166-
167-class SprintVocabulary(NamedSQLObjectVocabulary):
168- _table = Sprint
169-
170-
171 class BugWatchVocabulary(SQLObjectVocabularyBase):
172 _table = BugWatch
173
174
175=== modified file 'lib/lp/blueprints/browser/specificationbranch.py'
176--- lib/lp/blueprints/browser/specificationbranch.py 2010-08-20 20:31:18 +0000
177+++ lib/lp/blueprints/browser/specificationbranch.py 2010-09-26 22:54:42 +0000
178@@ -121,5 +121,4 @@
179 @action(_('Continue'), name='continue')
180 def continue_action(self, action, data):
181 spec = data['specification']
182- spec_branch = spec.linkBranch(
183- branch=self.context, registrant=self.user)
184+ spec.linkBranch(branch=self.context, registrant=self.user)
185
186=== modified file 'lib/lp/blueprints/interfaces/specificationbranch.py'
187--- lib/lp/blueprints/interfaces/specificationbranch.py 2010-08-20 20:31:18 +0000
188+++ lib/lp/blueprints/interfaces/specificationbranch.py 2010-09-26 22:54:42 +0000
189@@ -30,7 +30,6 @@
190 from lp.blueprints.interfaces.specification import ISpecification
191 from lp.code.interfaces.branch import IBranch
192 from lp.registry.interfaces.person import IPerson
193-from lp.services.fields import Summary
194
195
196 class ISpecificationBranch(IHasDateCreated):
197
198=== modified file 'lib/lp/blueprints/vocabularies/configure.zcml'
199--- lib/lp/blueprints/vocabularies/configure.zcml 2010-08-25 06:28:51 +0000
200+++ lib/lp/blueprints/vocabularies/configure.zcml 2010-09-26 22:54:42 +0000
201@@ -16,4 +16,52 @@
202 <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
203 </class>
204
205+ <securedutility
206+ name="Specification"
207+ component=".specification.SpecificationVocabulary"
208+ provides="zope.schema.interfaces.IVocabularyFactory"
209+ >
210+ <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
211+ </securedutility>
212+
213+ <class class=".specification.SpecificationVocabulary">
214+ <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
215+ </class>
216+
217+ <securedutility
218+ name="SpecificationDependencies"
219+ component=".specificationdependency.SpecificationDependenciesVocabulary"
220+ provides="zope.schema.interfaces.IVocabularyFactory"
221+ >
222+ <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
223+ </securedutility>
224+
225+ <class class=".specificationdependency.SpecificationDependenciesVocabulary">
226+ <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
227+ </class>
228+
229+ <securedutility
230+ name="Sprint"
231+ component=".sprint.SprintVocabulary"
232+ provides="zope.schema.interfaces.IVocabularyFactory"
233+ >
234+ <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
235+ </securedutility>
236+
237+ <securedutility
238+ name="FutureSprint"
239+ component=".sprint.FutureSprintVocabulary"
240+ provides="zope.schema.interfaces.IVocabularyFactory"
241+ >
242+ <allow interface="zope.schema.interfaces.IVocabularyFactory"/>
243+ </securedutility>
244+
245+ <class class=".sprint.FutureSprintVocabulary">
246+ <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
247+ </class>
248+
249+ <class class=".sprint.SprintVocabulary">
250+ <allow interface="canonical.launchpad.webapp.vocabulary.IHugeVocabulary"/>
251+ </class>
252+
253 </configure>
254
255=== added file 'lib/lp/blueprints/vocabularies/specification.py'
256--- lib/lp/blueprints/vocabularies/specification.py 1970-01-01 00:00:00 +0000
257+++ lib/lp/blueprints/vocabularies/specification.py 2010-09-26 22:54:42 +0000
258@@ -0,0 +1,55 @@
259+# Copyright 2010 Canonical Ltd. This software is licensed under the
260+# GNU Affero General Public License version 3 (see the file LICENSE).
261+
262+"""The vocabularies relating to specifications."""
263+
264+__metaclass__ = type
265+__all__ = [
266+ 'SpecificationVocabulary',
267+ ]
268+
269+from operator import attrgetter
270+
271+from zope.component import getUtility
272+from zope.schema.vocabulary import SimpleTerm
273+
274+from canonical.launchpad.webapp.interfaces import ILaunchBag
275+from canonical.launchpad.webapp.vocabulary import NamedSQLObjectVocabulary
276+
277+from lp.blueprints.model.specification import Specification
278+
279+
280+class SpecificationVocabulary(NamedSQLObjectVocabulary):
281+ """List specifications for the current product or distribution in
282+ ILaunchBag, EXCEPT for the current spec in LaunchBag if one exists.
283+ """
284+
285+ _table = Specification
286+ _orderBy = 'title'
287+
288+ def __iter__(self):
289+ launchbag = getUtility(ILaunchBag)
290+ target = None
291+ product = launchbag.product
292+ if product is not None:
293+ target = product
294+
295+ distribution = launchbag.distribution
296+ if distribution is not None:
297+ target = distribution
298+
299+ if target is not None:
300+ for spec in sorted(
301+ target.specifications(), key=attrgetter('title')):
302+ # we will not show the current specification in the
303+ # launchbag
304+ if spec == launchbag.specification:
305+ continue
306+ # we will not show a specification that is blocked on the
307+ # current specification in the launchbag. this is because
308+ # the widget is currently used to select new dependencies,
309+ # and we do not want to introduce circular dependencies.
310+ if launchbag.specification is not None:
311+ if spec in launchbag.specification.all_blocked:
312+ continue
313+ yield SimpleTerm(spec, spec.name, spec.title)
314
315=== modified file 'lib/lp/blueprints/vocabularies/specificationdependency.py'
316--- lib/lp/blueprints/vocabularies/specificationdependency.py 2010-08-27 04:35:55 +0000
317+++ lib/lp/blueprints/vocabularies/specificationdependency.py 2010-09-26 22:54:42 +0000
318@@ -4,7 +4,12 @@
319 """The vocabularies relating to dependencies of specifications."""
320
321 __metaclass__ = type
322-__all__ = ['SpecificationDepCandidatesVocabulary']
323+__all__ = [
324+ 'SpecificationDepCandidatesVocabulary',
325+ 'SpecificationDependenciesVocabulary',
326+ ]
327+
328+from operator import attrgetter
329
330 from zope.component import getUtility
331 from zope.interface import implements
332@@ -19,6 +24,7 @@
333 from canonical.launchpad.webapp.vocabulary import (
334 CountableIterator,
335 IHugeVocabulary,
336+ NamedSQLObjectVocabulary,
337 SQLObjectVocabularyBase,
338 )
339
340@@ -26,6 +32,7 @@
341 from lp.blueprints.model.specification import Specification
342 from lp.registry.interfaces.pillar import IPillarNameSet
343
344+
345 class SpecificationDepCandidatesVocabulary(SQLObjectVocabularyBase):
346 """Specifications that could be dependencies of this spec.
347
348@@ -158,3 +165,14 @@
349 def __contains__(self, obj):
350 return self._is_valid_candidate(obj)
351
352+
353+class SpecificationDependenciesVocabulary(NamedSQLObjectVocabulary):
354+ """List specifications on which the current specification depends."""
355+
356+ _table = Specification
357+ _orderBy = 'title'
358+
359+ def __iter__(self):
360+ for spec in sorted(
361+ self.context.dependencies, key=attrgetter('title')):
362+ yield SimpleTerm(spec, spec.name, spec.title)
363
364=== added file 'lib/lp/blueprints/vocabularies/sprint.py'
365--- lib/lp/blueprints/vocabularies/sprint.py 1970-01-01 00:00:00 +0000
366+++ lib/lp/blueprints/vocabularies/sprint.py 2010-09-26 22:54:42 +0000
367@@ -0,0 +1,30 @@
368+# Copyright 2010 Canonical Ltd. This software is licensed under the
369+# GNU Affero General Public License version 3 (see the file LICENSE).
370+
371+"""The vocabularies relating to sprints."""
372+
373+__metaclass__ = type
374+__all__ = [
375+ 'FutureSprintVocabulary',
376+ 'SprintVocabulary',
377+ ]
378+
379+
380+from canonical.launchpad.webapp.vocabulary import NamedSQLObjectVocabulary
381+
382+from lp.blueprints.model.sprint import Sprint
383+
384+
385+class FutureSprintVocabulary(NamedSQLObjectVocabulary):
386+ """A vocab of all sprints that have not yet finished."""
387+
388+ _table = Sprint
389+
390+ def __iter__(self):
391+ future_sprints = Sprint.select("time_ends > 'NOW'")
392+ for sprint in future_sprints:
393+ yield(self.toTerm(sprint))
394+
395+
396+class SprintVocabulary(NamedSQLObjectVocabulary):
397+ _table = Sprint