Merge lp:~mwhudson/launchpad/code-publisher-in-lp.code into lp:launchpad
- code-publisher-in-lp.code
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Curtis Hovey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11196 |
Proposed branch: | lp:~mwhudson/launchpad/code-publisher-in-lp.code |
Merge into: | lp:launchpad |
Diff against target: |
457 lines (+135/-43) 13 files modified
lib/canonical/configure.zcml (+2/-2) lib/canonical/launchpad/doc/webapp-publication.txt (+1/-7) lib/canonical/launchpad/layers.py (+0/-4) lib/canonical/launchpad/webapp/meta.zcml (+7/-0) lib/canonical/launchpad/webapp/metazcml.py (+20/-1) lib/canonical/launchpad/webapp/servers.py (+0/-9) lib/canonical/launchpad/zcml/marketing.zcml (+3/-3) lib/lp/app/tests/test_help.py (+3/-1) lib/lp/code/browser/configure.zcml (+14/-14) lib/lp/code/configure.zcml (+5/-1) lib/lp/code/publisher.py (+34/-0) lib/lp/code/tests/test_publisher.py (+45/-0) lib/lp/registry/browser/configure.zcml (+1/-1) |
To merge this branch: | bzr merge lp:~mwhudson/launchpad/code-publisher-in-lp.code |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Curtis Hovey (community) | Approve | ||
Review via email:
|
Commit message
Move the code-specific publication code into lp.code
Description of the change
Hi horsemen,
This branch moves the code-specific publication gubbins into lp.code. This was surprisingly easy!
The overriding of the zope:publisher ZCML to make priority optional is a bit odd, but it beats having to insert random values into the zcml imho. I also want to override this to make switching sites off possible based on config values later, so it's worth keeping the code to do that in here.
Cheers,
mwh
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hudson-Doyle (mwhudson) wrote : | # |
Hi, can you look at this again? It failed tests so I made a few more changes.
I think we could eliminate some boilerplate by writing our own ZCML directive, how would something like
<lp:site
name="code"
web_
request_
look to you?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Curtis Hovey (sinzui) wrote : | # |
I like the suggestion. IT is not clear that site is a vhost. The directive could be vhost, but I think vhost="code" is most clear.
Preview Diff
1 | === modified file 'lib/canonical/configure.zcml' | |||
2 | --- lib/canonical/configure.zcml 2010-07-15 15:57:40 +0000 | |||
3 | +++ lib/canonical/configure.zcml 2010-07-20 23:57:54 +0000 | |||
4 | @@ -99,14 +99,14 @@ | |||
5 | 99 | <browser:defaultView | 99 | <browser:defaultView |
6 | 100 | for="canonical.launchpad.interfaces.ILaunchpadRoot" | 100 | for="canonical.launchpad.interfaces.ILaunchpadRoot" |
7 | 101 | name="+code" | 101 | name="+code" |
9 | 102 | layer="canonical.launchpad.layers.CodeLayer" | 102 | layer="lp.code.publisher.CodeLayer" |
10 | 103 | /> | 103 | /> |
11 | 104 | <browser:page | 104 | <browser:page |
12 | 105 | name="" | 105 | name="" |
13 | 106 | for="canonical.launchpad.interfaces.ILaunchpadRoot" | 106 | for="canonical.launchpad.interfaces.ILaunchpadRoot" |
14 | 107 | class="canonical.launchpad.browser.launchpad.LaunchpadImageFolder" | 107 | class="canonical.launchpad.browser.launchpad.LaunchpadImageFolder" |
15 | 108 | permission="zope.Public" | 108 | permission="zope.Public" |
17 | 109 | layer="canonical.launchpad.layers.CodeLayer" | 109 | layer="lp.code.publisher.CodeLayer" |
18 | 110 | /> | 110 | /> |
19 | 111 | 111 | ||
20 | 112 | <!-- virtual host: translations --> | 112 | <!-- virtual host: translations --> |
21 | 113 | 113 | ||
22 | === modified file 'lib/canonical/launchpad/doc/webapp-publication.txt' | |||
23 | --- lib/canonical/launchpad/doc/webapp-publication.txt 2010-03-02 03:22:01 +0000 | |||
24 | +++ lib/canonical/launchpad/doc/webapp-publication.txt 2010-07-20 23:57:54 +0000 | |||
25 | @@ -372,10 +372,6 @@ | |||
26 | 372 | BugsBrowserRequest | 372 | BugsBrowserRequest |
27 | 373 | BugsPublication | 373 | BugsPublication |
28 | 374 | 374 | ||
29 | 375 | >>> print_request_and_publication('code.launchpad.dev') | ||
30 | 376 | CodeBrowserRequest | ||
31 | 377 | CodePublication | ||
32 | 378 | |||
33 | 379 | >>> print_request_and_publication('feeds.launchpad.dev') | 375 | >>> print_request_and_publication('feeds.launchpad.dev') |
34 | 380 | FeedsBrowserRequest | 376 | FeedsBrowserRequest |
35 | 381 | FeedsPublication | 377 | FeedsPublication |
36 | @@ -417,7 +413,7 @@ | |||
37 | 417 | WebServiceClientRequest | 413 | WebServiceClientRequest |
38 | 418 | WebServicePublication | 414 | WebServicePublication |
39 | 419 | >>> for subdomain in [ | 415 | >>> for subdomain in [ |
41 | 420 | ... 'answers', 'blueprints', 'bugs', 'code', 'translations']: | 416 | ... 'answers', 'blueprints', 'bugs', 'translations']: |
42 | 421 | ... print_request_and_publication( | 417 | ... print_request_and_publication( |
43 | 422 | ... '%s.launchpad.dev' % subdomain, method='GET', | 418 | ... '%s.launchpad.dev' % subdomain, method='GET', |
44 | 423 | ... extra_environment={'PATH_INFO': '/api'}) | 419 | ... extra_environment={'PATH_INFO': '/api'}) |
45 | @@ -429,8 +425,6 @@ | |||
46 | 429 | WebServicePublication | 425 | WebServicePublication |
47 | 430 | WebServiceClientRequest | 426 | WebServiceClientRequest |
48 | 431 | WebServicePublication | 427 | WebServicePublication |
49 | 432 | WebServiceClientRequest | ||
50 | 433 | WebServicePublication | ||
51 | 434 | 428 | ||
52 | 435 | Requests for '/api' on other hosts like feeds are handled like | 429 | Requests for '/api' on other hosts like feeds are handled like |
53 | 436 | other requests on these hosts: | 430 | other requests on these hosts: |
54 | 437 | 431 | ||
55 | === modified file 'lib/canonical/launchpad/layers.py' | |||
56 | --- lib/canonical/launchpad/layers.py 2009-12-25 22:36:11 +0000 | |||
57 | +++ lib/canonical/launchpad/layers.py 2010-07-20 23:57:54 +0000 | |||
58 | @@ -36,10 +36,6 @@ | |||
59 | 36 | """The `BugsLayer` layer.""" | 36 | """The `BugsLayer` layer.""" |
60 | 37 | 37 | ||
61 | 38 | 38 | ||
62 | 39 | class CodeLayer(LaunchpadLayer): | ||
63 | 40 | """The `CodeLayer` layer.""" | ||
64 | 41 | |||
65 | 42 | |||
66 | 43 | class BlueprintLayer(LaunchpadLayer): | 39 | class BlueprintLayer(LaunchpadLayer): |
67 | 44 | """The `BlueprintLayer` layer.""" | 40 | """The `BlueprintLayer` layer.""" |
68 | 45 | BlueprintsLayer = BlueprintLayer | 41 | BlueprintsLayer = BlueprintLayer |
69 | 46 | 42 | ||
70 | === modified file 'lib/canonical/launchpad/webapp/meta.zcml' | |||
71 | --- lib/canonical/launchpad/webapp/meta.zcml 2009-07-13 18:15:02 +0000 | |||
72 | +++ lib/canonical/launchpad/webapp/meta.zcml 2010-07-20 23:57:54 +0000 | |||
73 | @@ -69,6 +69,13 @@ | |||
74 | 69 | handler="canonical.launchpad.webapp.metazcml.authorizations" | 69 | handler="canonical.launchpad.webapp.metazcml.authorizations" |
75 | 70 | /> | 70 | /> |
76 | 71 | 71 | ||
77 | 72 | <directive | ||
78 | 73 | namespace="http://namespaces.zope.org/zope" | ||
79 | 74 | name="publisher" | ||
80 | 75 | schema="canonical.launchpad.webapp.metazcml.ILaunchpadPublicationDirective" | ||
81 | 76 | handler="canonical.launchpad.webapp.metazcml.launchpadPublisher" | ||
82 | 77 | /> | ||
83 | 78 | |||
84 | 72 | <groupingDirective | 79 | <groupingDirective |
85 | 73 | namespace="http://namespaces.zope.org/zope" | 80 | namespace="http://namespaces.zope.org/zope" |
86 | 74 | name="facet" | 81 | name="facet" |
87 | 75 | 82 | ||
88 | === modified file 'lib/canonical/launchpad/webapp/metazcml.py' | |||
89 | --- lib/canonical/launchpad/webapp/metazcml.py 2010-04-11 14:46:42 +0000 | |||
90 | +++ lib/canonical/launchpad/webapp/metazcml.py 2010-07-20 23:57:54 +0000 | |||
91 | @@ -10,6 +10,8 @@ | |||
92 | 10 | import zope.configuration.config | 10 | import zope.configuration.config |
93 | 11 | from zope.app.file.image import Image | 11 | from zope.app.file.image import Image |
94 | 12 | from zope.app.pagetemplate.engine import TrustedEngine | 12 | from zope.app.pagetemplate.engine import TrustedEngine |
95 | 13 | from zope.app.publication.metaconfigure import publisher | ||
96 | 14 | from zope.app.publication.metadirectives import IRequestPublicationDirective | ||
97 | 13 | from zope.component import getUtility | 15 | from zope.component import getUtility |
98 | 14 | from zope.component.security import PublicPermission | 16 | from zope.component.security import PublicPermission |
99 | 15 | from zope.component.zcml import adapter, handler, utility, view | 17 | from zope.component.zcml import adapter, handler, utility, view |
100 | @@ -19,7 +21,7 @@ | |||
101 | 19 | from zope.publisher.interfaces.browser import ( | 21 | from zope.publisher.interfaces.browser import ( |
102 | 20 | IBrowserPublisher, IBrowserRequest, IDefaultBrowserLayer) | 22 | IBrowserPublisher, IBrowserRequest, IDefaultBrowserLayer) |
103 | 21 | from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest | 23 | from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest |
105 | 22 | from zope.schema import TextLine | 24 | from zope.schema import Int, TextLine |
106 | 23 | from zope.security.checker import Checker, CheckerPublic | 25 | from zope.security.checker import Checker, CheckerPublic |
107 | 24 | from zope.security.interfaces import IPermission | 26 | from zope.security.interfaces import IPermission |
108 | 25 | from zope.security.permission import Permission | 27 | from zope.security.permission import Permission |
109 | @@ -33,6 +35,7 @@ | |||
110 | 33 | from z3c.ptcompat.zcml import page_directive as original_page | 35 | from z3c.ptcompat.zcml import page_directive as original_page |
111 | 34 | from z3c.ptcompat.zcml import pages_directive as original_pages | 36 | from z3c.ptcompat.zcml import pages_directive as original_pages |
112 | 35 | 37 | ||
113 | 38 | from canonical.config import config | ||
114 | 36 | from canonical.launchpad.layers import FeedsLayer | 39 | from canonical.launchpad.layers import FeedsLayer |
115 | 37 | from canonical.launchpad.webapp.interfaces import ( | 40 | from canonical.launchpad.webapp.interfaces import ( |
116 | 38 | IApplicationMenu, IAuthorization, ICanonicalUrlData, IContextMenu, | 41 | IApplicationMenu, IAuthorization, ICanonicalUrlData, IContextMenu, |
117 | @@ -651,3 +654,19 @@ | |||
118 | 651 | description=''): | 654 | description=''): |
119 | 652 | permission = LaunchpadPermission(id, title, access_level, description) | 655 | permission = LaunchpadPermission(id, title, access_level, description) |
120 | 653 | utility(_context, ILaunchpadPermission, permission, name=id) | 656 | utility(_context, ILaunchpadPermission, permission, name=id) |
121 | 657 | |||
122 | 658 | |||
123 | 659 | class ILaunchpadPublicationDirective(IRequestPublicationDirective): | ||
124 | 660 | |||
125 | 661 | priorty = Int(required=False) | ||
126 | 662 | |||
127 | 663 | _arbitrary_priority = 12 | ||
128 | 664 | |||
129 | 665 | |||
130 | 666 | def launchpadPublisher(_context, name, factory, methods=['*'], | ||
131 | 667 | mimetypes=['*'], priority=None): | ||
132 | 668 | global _arbitrary_priority | ||
133 | 669 | if priority is None: | ||
134 | 670 | _arbitrary_priority += 1 | ||
135 | 671 | priority = _arbitrary_priority | ||
136 | 672 | publisher(_context, name, factory, methods, mimetypes, priority) | ||
137 | 654 | 673 | ||
138 | === modified file 'lib/canonical/launchpad/webapp/servers.py' | |||
139 | --- lib/canonical/launchpad/webapp/servers.py 2010-07-19 14:45:32 +0000 | |||
140 | +++ lib/canonical/launchpad/webapp/servers.py 2010-07-20 23:57:54 +0000 | |||
141 | @@ -1023,14 +1023,6 @@ | |||
142 | 1023 | class BlueprintPublication(LaunchpadBrowserPublication): | 1023 | class BlueprintPublication(LaunchpadBrowserPublication): |
143 | 1024 | """The publication used for the Blueprint site.""" | 1024 | """The publication used for the Blueprint site.""" |
144 | 1025 | 1025 | ||
145 | 1026 | # ---- code | ||
146 | 1027 | |||
147 | 1028 | class CodePublication(LaunchpadBrowserPublication): | ||
148 | 1029 | """The publication used for the Code site.""" | ||
149 | 1030 | |||
150 | 1031 | class CodeBrowserRequest(LaunchpadBrowserRequest): | ||
151 | 1032 | implements(canonical.launchpad.layers.CodeLayer) | ||
152 | 1033 | |||
153 | 1034 | # ---- translations | 1026 | # ---- translations |
154 | 1035 | 1027 | ||
155 | 1036 | class TranslationsPublication(LaunchpadBrowserPublication): | 1028 | class TranslationsPublication(LaunchpadBrowserPublication): |
156 | @@ -1484,7 +1476,6 @@ | |||
157 | 1484 | VWSHRP('mainsite', LaunchpadBrowserRequest, MainLaunchpadPublication, | 1476 | VWSHRP('mainsite', LaunchpadBrowserRequest, MainLaunchpadPublication, |
158 | 1485 | handle_default_host=True), | 1477 | handle_default_host=True), |
159 | 1486 | VWSHRP('blueprints', BlueprintBrowserRequest, BlueprintPublication), | 1478 | VWSHRP('blueprints', BlueprintBrowserRequest, BlueprintPublication), |
160 | 1487 | VWSHRP('code', CodeBrowserRequest, CodePublication), | ||
161 | 1488 | VWSHRP('translations', TranslationsBrowserRequest, | 1479 | VWSHRP('translations', TranslationsBrowserRequest, |
162 | 1489 | TranslationsPublication), | 1480 | TranslationsPublication), |
163 | 1490 | VWSHRP('bugs', BugsBrowserRequest, BugsPublication), | 1481 | VWSHRP('bugs', BugsBrowserRequest, BugsPublication), |
164 | 1491 | 1482 | ||
165 | === modified file 'lib/canonical/launchpad/zcml/marketing.zcml' | |||
166 | --- lib/canonical/launchpad/zcml/marketing.zcml 2009-07-13 18:15:02 +0000 | |||
167 | +++ lib/canonical/launchpad/zcml/marketing.zcml 2010-07-20 23:57:54 +0000 | |||
168 | @@ -95,14 +95,14 @@ | |||
169 | 95 | <!-- Marketing material for Code. --> | 95 | <!-- Marketing material for Code. --> |
170 | 96 | <browser:renamed-page | 96 | <browser:renamed-page |
171 | 97 | for="canonical.launchpad.webapp.interfaces.ILaunchpadApplication" | 97 | for="canonical.launchpad.webapp.interfaces.ILaunchpadApplication" |
173 | 98 | layer="canonical.launchpad.layers.CodeLayer" | 98 | layer="lp.code.publisher.CodeLayer" |
174 | 99 | name="+about" | 99 | name="+about" |
175 | 100 | new_name="+tour/branch-hosting-tracking" | 100 | new_name="+tour/branch-hosting-tracking" |
176 | 101 | rootsite="mainsite" | 101 | rootsite="mainsite" |
177 | 102 | /> | 102 | /> |
178 | 103 | <browser:renamed-page | 103 | <browser:renamed-page |
179 | 104 | for="canonical.launchpad.webapp.interfaces.ILaunchpadApplication" | 104 | for="canonical.launchpad.webapp.interfaces.ILaunchpadApplication" |
181 | 105 | layer="canonical.launchpad.layers.CodeLayer" | 105 | layer="lp.code.publisher.CodeLayer" |
182 | 106 | name="+faq" | 106 | name="+faq" |
183 | 107 | new_name="+tour/branch-hosting-tracking" | 107 | new_name="+tour/branch-hosting-tracking" |
184 | 108 | rootsite="mainsite" | 108 | rootsite="mainsite" |
185 | @@ -110,7 +110,7 @@ | |||
186 | 110 | <browser:renamed-page | 110 | <browser:renamed-page |
187 | 111 | name="+tour" | 111 | name="+tour" |
188 | 112 | for="canonical.launchpad.webapp.interfaces.ILaunchpadApplication" | 112 | for="canonical.launchpad.webapp.interfaces.ILaunchpadApplication" |
190 | 113 | layer="canonical.launchpad.layers.CodeLayer" | 113 | layer="lp.code.publisher.CodeLayer" |
191 | 114 | new_name="+tour/branch-hosting-tracking" | 114 | new_name="+tour/branch-hosting-tracking" |
192 | 115 | rootsite="mainsite" | 115 | rootsite="mainsite" |
193 | 116 | /> | 116 | /> |
194 | 117 | 117 | ||
195 | === modified file 'lib/lp/app/tests/test_help.py' | |||
196 | --- lib/lp/app/tests/test_help.py 2010-07-18 00:23:02 +0000 | |||
197 | +++ lib/lp/app/tests/test_help.py 2010-07-20 23:57:54 +0000 | |||
198 | @@ -11,13 +11,15 @@ | |||
199 | 11 | 11 | ||
200 | 12 | from canonical.testing.layers import FunctionalLayer | 12 | from canonical.testing.layers import FunctionalLayer |
201 | 13 | from canonical.launchpad.layers import ( | 13 | from canonical.launchpad.layers import ( |
203 | 14 | AnswersLayer, BlueprintsLayer, BugsLayer, CodeLayer, LaunchpadLayer, | 14 | AnswersLayer, BlueprintsLayer, BugsLayer, LaunchpadLayer, |
204 | 15 | TranslationsLayer) | 15 | TranslationsLayer) |
205 | 16 | from canonical.launchpad.testing.systemdocs import create_view | 16 | from canonical.launchpad.testing.systemdocs import create_view |
206 | 17 | from canonical.launchpad.webapp.interfaces import ILaunchpadApplication | 17 | from canonical.launchpad.webapp.interfaces import ILaunchpadApplication |
207 | 18 | 18 | ||
208 | 19 | from canonical.lazr.folder import ExportedFolder | 19 | from canonical.lazr.folder import ExportedFolder |
209 | 20 | 20 | ||
210 | 21 | from lp.code.publisher import CodeLayer | ||
211 | 22 | |||
212 | 21 | # The root of the tree | 23 | # The root of the tree |
213 | 22 | ROOT = os.path.realpath( | 24 | ROOT = os.path.realpath( |
214 | 23 | os.path.join( | 25 | os.path.join( |
215 | 24 | 26 | ||
216 | === modified file 'lib/lp/code/browser/configure.zcml' | |||
217 | --- lib/lp/code/browser/configure.zcml 2010-07-14 10:09:35 +0000 | |||
218 | +++ lib/lp/code/browser/configure.zcml 2010-07-20 23:57:54 +0000 | |||
219 | @@ -18,11 +18,11 @@ | |||
220 | 18 | 18 | ||
221 | 19 | <browser:defaultView | 19 | <browser:defaultView |
222 | 20 | for="lp.registry.interfaces.product.IProductSet" | 20 | for="lp.registry.interfaces.product.IProductSet" |
224 | 21 | layer="canonical.launchpad.layers.CodeLayer" | 21 | layer="lp.code.publisher.CodeLayer" |
225 | 22 | name="+project-cloud"/> | 22 | name="+project-cloud"/> |
226 | 23 | <browser:page | 23 | <browser:page |
227 | 24 | for="lp.registry.interfaces.product.IProductSet" | 24 | for="lp.registry.interfaces.product.IProductSet" |
229 | 25 | layer="canonical.launchpad.layers.CodeLayer" | 25 | layer="lp.code.publisher.CodeLayer" |
230 | 26 | name="+project-cloud" | 26 | name="+project-cloud" |
231 | 27 | class="lp.code.browser.bazaar.BazaarProductView" | 27 | class="lp.code.browser.bazaar.BazaarProductView" |
232 | 28 | template="../templates/code-in-branches.pt" | 28 | template="../templates/code-in-branches.pt" |
233 | @@ -87,7 +87,7 @@ | |||
234 | 87 | <browser:defaultView | 87 | <browser:defaultView |
235 | 88 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachine" | 88 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachine" |
236 | 89 | name="+index" | 89 | name="+index" |
238 | 90 | layer="canonical.launchpad.layers.CodeLayer"/> | 90 | layer="lp.code.publisher.CodeLayer"/> |
239 | 91 | <browser:page | 91 | <browser:page |
240 | 92 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachine" | 92 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachine" |
241 | 93 | class="lp.code.browser.codeimportmachine.CodeImportMachineView" | 93 | class="lp.code.browser.codeimportmachine.CodeImportMachineView" |
242 | @@ -109,7 +109,7 @@ | |||
243 | 109 | <browser:defaultView | 109 | <browser:defaultView |
244 | 110 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachineSet" | 110 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachineSet" |
245 | 111 | name="+index" | 111 | name="+index" |
247 | 112 | layer="canonical.launchpad.layers.CodeLayer"/> | 112 | layer="lp.code.publisher.CodeLayer"/> |
248 | 113 | <browser:page | 113 | <browser:page |
249 | 114 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachineSet" | 114 | for="lp.code.interfaces.codeimportmachine.ICodeImportMachineSet" |
250 | 115 | class="lp.code.browser.codeimportmachine.CodeImportMachineSetView" | 115 | class="lp.code.browser.codeimportmachine.CodeImportMachineSetView" |
251 | @@ -685,7 +685,7 @@ | |||
252 | 685 | <browser:defaultView | 685 | <browser:defaultView |
253 | 686 | for="lp.code.interfaces.codeimport.ICodeImportSet" | 686 | for="lp.code.interfaces.codeimport.ICodeImportSet" |
254 | 687 | name="+index" | 687 | name="+index" |
256 | 688 | layer="canonical.launchpad.layers.CodeLayer"/> | 688 | layer="lp.code.publisher.CodeLayer"/> |
257 | 689 | <browser:page | 689 | <browser:page |
258 | 690 | for="lp.code.interfaces.codeimport.ICodeImportSet" | 690 | for="lp.code.interfaces.codeimport.ICodeImportSet" |
259 | 691 | class="lp.code.browser.codeimport.CodeImportSetView" | 691 | class="lp.code.browser.codeimport.CodeImportSetView" |
260 | @@ -717,7 +717,7 @@ | |||
261 | 717 | <browser:defaultView | 717 | <browser:defaultView |
262 | 718 | for="lp.registry.interfaces.projectgroup.IProjectGroup" | 718 | for="lp.registry.interfaces.projectgroup.IProjectGroup" |
263 | 719 | name="+branches" | 719 | name="+branches" |
265 | 720 | layer="canonical.launchpad.layers.CodeLayer"/> | 720 | layer="lp.code.publisher.CodeLayer"/> |
266 | 721 | <browser:page | 721 | <browser:page |
267 | 722 | for="lp.registry.interfaces.sourcepackage.ISourcePackage" | 722 | for="lp.registry.interfaces.sourcepackage.ISourcePackage" |
268 | 723 | class="lp.code.browser.branchlisting.SourcePackageBranchesView" | 723 | class="lp.code.browser.branchlisting.SourcePackageBranchesView" |
269 | @@ -804,7 +804,7 @@ | |||
270 | 804 | PersonBranchesMenu"/> | 804 | PersonBranchesMenu"/> |
271 | 805 | <browser:defaultView | 805 | <browser:defaultView |
272 | 806 | for="lp.registry.interfaces.person.IPerson" | 806 | for="lp.registry.interfaces.person.IPerson" |
274 | 807 | layer="canonical.launchpad.layers.CodeLayer" | 807 | layer="lp.code.publisher.CodeLayer" |
275 | 808 | name="+branches"/> | 808 | name="+branches"/> |
276 | 809 | <browser:page | 809 | <browser:page |
277 | 810 | for="lp.registry.interfaces.person.IPerson" | 810 | for="lp.registry.interfaces.person.IPerson" |
278 | @@ -914,22 +914,22 @@ | |||
279 | 914 | 914 | ||
280 | 915 | <browser:defaultView | 915 | <browser:defaultView |
281 | 916 | for="lp.registry.interfaces.sourcepackage.ISourcePackage" | 916 | for="lp.registry.interfaces.sourcepackage.ISourcePackage" |
283 | 917 | layer="canonical.launchpad.layers.CodeLayer" | 917 | layer="lp.code.publisher.CodeLayer" |
284 | 918 | name="+branches"/> | 918 | name="+branches"/> |
285 | 919 | 919 | ||
286 | 920 | <browser:defaultView | 920 | <browser:defaultView |
287 | 921 | for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage" | 921 | for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage" |
289 | 922 | layer="canonical.launchpad.layers.CodeLayer" | 922 | layer="lp.code.publisher.CodeLayer" |
290 | 923 | name="+code-index"/> | 923 | name="+code-index"/> |
291 | 924 | 924 | ||
292 | 925 | <browser:defaultView | 925 | <browser:defaultView |
293 | 926 | for="lp.registry.interfaces.distribution.IDistribution" | 926 | for="lp.registry.interfaces.distribution.IDistribution" |
295 | 927 | layer="canonical.launchpad.layers.CodeLayer" | 927 | layer="lp.code.publisher.CodeLayer" |
296 | 928 | name="+branches"/> | 928 | name="+branches"/> |
297 | 929 | 929 | ||
298 | 930 | <browser:defaultView | 930 | <browser:defaultView |
299 | 931 | for="lp.registry.interfaces.distroseries.IDistroSeries" | 931 | for="lp.registry.interfaces.distroseries.IDistroSeries" |
301 | 932 | layer="canonical.launchpad.layers.CodeLayer" | 932 | layer="lp.code.publisher.CodeLayer" |
302 | 933 | name="+branches"/> | 933 | name="+branches"/> |
303 | 934 | 934 | ||
304 | 935 | <browser:url | 935 | <browser:url |
305 | @@ -956,7 +956,7 @@ | |||
306 | 956 | 956 | ||
307 | 957 | <browser:defaultView | 957 | <browser:defaultView |
308 | 958 | for="lp.registry.interfaces.personproduct.IPersonProduct" | 958 | for="lp.registry.interfaces.personproduct.IPersonProduct" |
310 | 959 | layer="canonical.launchpad.layers.CodeLayer" | 959 | layer="lp.code.publisher.CodeLayer" |
311 | 960 | name="+branches" /> | 960 | name="+branches" /> |
312 | 961 | 961 | ||
313 | 962 | <browser:page | 962 | <browser:page |
314 | @@ -1099,7 +1099,7 @@ | |||
315 | 1099 | <browser:defaultView | 1099 | <browser:defaultView |
316 | 1100 | for="lp.code.interfaces.sourcepackagerecipe.ISourcePackageRecipe" | 1100 | for="lp.code.interfaces.sourcepackagerecipe.ISourcePackageRecipe" |
317 | 1101 | name="+index" | 1101 | name="+index" |
319 | 1102 | layer="canonical.launchpad.layers.CodeLayer"/> | 1102 | layer="lp.code.publisher.CodeLayer"/> |
320 | 1103 | <browser:page | 1103 | <browser:page |
321 | 1104 | for="lp.code.interfaces.sourcepackagerecipe.ISourcePackageRecipe" | 1104 | for="lp.code.interfaces.sourcepackagerecipe.ISourcePackageRecipe" |
322 | 1105 | class="lp.code.browser.sourcepackagerecipe.SourcePackageRecipeView" | 1105 | class="lp.code.browser.sourcepackagerecipe.SourcePackageRecipeView" |
323 | @@ -1117,7 +1117,7 @@ | |||
324 | 1117 | <browser:defaultView | 1117 | <browser:defaultView |
325 | 1118 | for="lp.code.interfaces.sourcepackagerecipebuild.ISourcePackageRecipeBuild" | 1118 | for="lp.code.interfaces.sourcepackagerecipebuild.ISourcePackageRecipeBuild" |
326 | 1119 | name="+index" | 1119 | name="+index" |
328 | 1120 | layer="canonical.launchpad.layers.CodeLayer"/> | 1120 | layer="lp.code.publisher.CodeLayer"/> |
329 | 1121 | <browser:page | 1121 | <browser:page |
330 | 1122 | for="lp.code.interfaces.sourcepackagerecipebuild.ISourcePackageRecipeBuild" | 1122 | for="lp.code.interfaces.sourcepackagerecipebuild.ISourcePackageRecipeBuild" |
331 | 1123 | class="lp.code.browser.sourcepackagerecipebuild.SourcePackageRecipeBuildView" | 1123 | class="lp.code.browser.sourcepackagerecipebuild.SourcePackageRecipeBuildView" |
332 | 1124 | 1124 | ||
333 | === modified file 'lib/lp/code/configure.zcml' | |||
334 | --- lib/lp/code/configure.zcml 2010-06-16 18:18:32 +0000 | |||
335 | +++ lib/lp/code/configure.zcml 2010-07-20 23:57:54 +0000 | |||
336 | @@ -13,6 +13,10 @@ | |||
337 | 13 | <include package=".browser"/> | 13 | <include package=".browser"/> |
338 | 14 | <authorizations module="lp.code.security" /> | 14 | <authorizations module="lp.code.security" /> |
339 | 15 | 15 | ||
340 | 16 | <publisher | ||
341 | 17 | name="code" | ||
342 | 18 | factory="lp.code.publisher.code_request_publication_factory"/> | ||
343 | 19 | |||
344 | 16 | <!-- Branch Merge Queue --> | 20 | <!-- Branch Merge Queue --> |
345 | 17 | 21 | ||
346 | 18 | <class class="lp.code.model.branchmergequeue.SingleBranchMergeQueue"> | 22 | <class class="lp.code.model.branchmergequeue.SingleBranchMergeQueue"> |
347 | @@ -981,7 +985,7 @@ | |||
348 | 981 | <adapter factory="lp.code.model.linkedbranch.DistributionPackageLinkedBranch" /> | 985 | <adapter factory="lp.code.model.linkedbranch.DistributionPackageLinkedBranch" /> |
349 | 982 | 986 | ||
350 | 983 | <lp:help-folder | 987 | <lp:help-folder |
352 | 984 | folder="help" type="canonical.launchpad.layers.CodeLayer" /> | 988 | folder="help" type="lp.code.publisher.CodeLayer" /> |
353 | 985 | 989 | ||
354 | 986 | <!-- Diffs --> | 990 | <!-- Diffs --> |
355 | 987 | <class class="lp.code.model.diff.Diff"> | 991 | <class class="lp.code.model.diff.Diff"> |
356 | 988 | 992 | ||
357 | === added file 'lib/lp/code/publisher.py' | |||
358 | --- lib/lp/code/publisher.py 1970-01-01 00:00:00 +0000 | |||
359 | +++ lib/lp/code/publisher.py 2010-07-20 23:57:54 +0000 | |||
360 | @@ -0,0 +1,34 @@ | |||
361 | 1 | # Copyright 2010 Canonical Ltd. This software is licensed under the | ||
362 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
363 | 3 | |||
364 | 4 | """Code's custom publication.""" | ||
365 | 5 | |||
366 | 6 | __metaclass__ = type | ||
367 | 7 | __all__ = [ | ||
368 | 8 | 'CodeBrowserRequest', | ||
369 | 9 | 'CodeLayer', | ||
370 | 10 | 'code_request_publication_factory', | ||
371 | 11 | ] | ||
372 | 12 | |||
373 | 13 | |||
374 | 14 | from zope.interface import implements | ||
375 | 15 | from zope.publisher.interfaces.browser import ( | ||
376 | 16 | IBrowserRequest, IDefaultBrowserLayer) | ||
377 | 17 | |||
378 | 18 | from canonical.launchpad.webapp.publication import LaunchpadBrowserPublication | ||
379 | 19 | from canonical.launchpad.webapp.servers import ( | ||
380 | 20 | LaunchpadBrowserRequest, VHostWebServiceRequestPublicationFactory) | ||
381 | 21 | |||
382 | 22 | |||
383 | 23 | class CodeLayer(IBrowserRequest, IDefaultBrowserLayer): | ||
384 | 24 | """The Code layer.""" | ||
385 | 25 | |||
386 | 26 | |||
387 | 27 | class CodeBrowserRequest(LaunchpadBrowserRequest): | ||
388 | 28 | """Instances of CodeBrowserRequest provide `CodeLayer`.""" | ||
389 | 29 | implements(CodeLayer) | ||
390 | 30 | |||
391 | 31 | |||
392 | 32 | def code_request_publication_factory(): | ||
393 | 33 | return VHostWebServiceRequestPublicationFactory( | ||
394 | 34 | 'code', CodeBrowserRequest, LaunchpadBrowserPublication) | ||
395 | 0 | 35 | ||
396 | === added file 'lib/lp/code/tests/test_publisher.py' | |||
397 | --- lib/lp/code/tests/test_publisher.py 1970-01-01 00:00:00 +0000 | |||
398 | +++ lib/lp/code/tests/test_publisher.py 2010-07-20 23:57:54 +0000 | |||
399 | @@ -0,0 +1,45 @@ | |||
400 | 1 | # Copyright 2010 Canonical Ltd. This software is licensed under the | ||
401 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
402 | 3 | |||
403 | 4 | """Tests for code's custom publications.""" | ||
404 | 5 | |||
405 | 6 | __metaclass__ = type | ||
406 | 7 | |||
407 | 8 | import unittest | ||
408 | 9 | |||
409 | 10 | from canonical.config import config | ||
410 | 11 | from canonical.launchpad.layers import WebServiceLayer | ||
411 | 12 | from canonical.testing.layers import FunctionalLayer | ||
412 | 13 | |||
413 | 14 | from lp.testing import TestCase | ||
414 | 15 | from lp.testing.publication import get_request_and_publication | ||
415 | 16 | |||
416 | 17 | from lp.code.publisher import CodeLayer | ||
417 | 18 | |||
418 | 19 | |||
419 | 20 | class TestRegistration(TestCase): | ||
420 | 21 | """Code's publication customizations are installed correctly.""" | ||
421 | 22 | |||
422 | 23 | layer = FunctionalLayer | ||
423 | 24 | |||
424 | 25 | def test_code_request_provides_code_layer(self): | ||
425 | 26 | # The request constructed for requests to the code hostname provides | ||
426 | 27 | # CodeLayer. | ||
427 | 28 | request, publication = get_request_and_publication( | ||
428 | 29 | host=config.vhost.code.hostname) | ||
429 | 30 | self.assertProvides(request, CodeLayer) | ||
430 | 31 | |||
431 | 32 | def test_code_host_has_api(self): | ||
432 | 33 | # Requests to /api on the code domain are treated as web service | ||
433 | 34 | # requests. | ||
434 | 35 | request, publication = get_request_and_publication( | ||
435 | 36 | host=config.vhost.code.hostname, | ||
436 | 37 | extra_environment={'PATH_INFO': '/api/1.0'}) | ||
437 | 38 | # XXX MichaelHudson, 2010-07-20, bug=607664: WebServiceLayer only | ||
438 | 39 | # actually provides WebServiceLayer in the sense of verifyObject after | ||
439 | 40 | # traversal has started. | ||
440 | 41 | self.assertTrue(WebServiceLayer.providedBy(request)) | ||
441 | 42 | |||
442 | 43 | |||
443 | 44 | def test_suite(): | ||
444 | 45 | return unittest.TestLoader().loadTestsFromName(__name__) | ||
445 | 0 | 46 | ||
446 | === modified file 'lib/lp/registry/browser/configure.zcml' | |||
447 | --- lib/lp/registry/browser/configure.zcml 2010-05-27 04:10:17 +0000 | |||
448 | +++ lib/lp/registry/browser/configure.zcml 2010-07-20 23:57:54 +0000 | |||
449 | @@ -1357,7 +1357,7 @@ | |||
450 | 1357 | <browser:defaultView | 1357 | <browser:defaultView |
451 | 1358 | for="lp.registry.interfaces.product.IProduct" | 1358 | for="lp.registry.interfaces.product.IProduct" |
452 | 1359 | name="+code-index" | 1359 | name="+code-index" |
454 | 1360 | layer="canonical.launchpad.layers.CodeLayer"/> | 1360 | layer="lp.code.publisher.CodeLayer"/> |
455 | 1361 | <browser:defaultView | 1361 | <browser:defaultView |
456 | 1362 | for="lp.registry.interfaces.product.IProduct" | 1362 | for="lp.registry.interfaces.product.IProduct" |
457 | 1363 | layer="canonical.launchpad.layers.AnswersLayer" | 1363 | layer="canonical.launchpad.layers.AnswersLayer" |
This looks good to land. I pondered the new metazcml directive. I think we need to dismantle webapp before we add some more to it.