11128.6.1
by Michael Hudson
move answers code out |
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 |
"""Answers's custom publication."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
7 |
__all__ = [ |
|
8 |
'AnswersBrowserRequest', |
|
9 |
'AnswersLayer', |
|
10 |
'answers_request_publication_factory', |
|
11 |
]
|
|
12 |
||
13 |
||
14 |
from zope.interface import implements |
|
15 |
from zope.publisher.interfaces.browser import ( |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
16 |
IBrowserRequest, |
17 |
IDefaultBrowserLayer, |
|
18 |
)
|
|
11128.6.1
by Michael Hudson
move answers code out |
19 |
|
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
20 |
from lp.services.webapp.publication import LaunchpadBrowserPublication |
21 |
from lp.services.webapp.servers import ( |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
22 |
LaunchpadBrowserRequest, |
23 |
VHostWebServiceRequestPublicationFactory, |
|
24 |
)
|
|
11128.6.1
by Michael Hudson
move answers code out |
25 |
|
26 |
||
27 |
class AnswersLayer(IBrowserRequest, IDefaultBrowserLayer): |
|
28 |
"""The Answers layer."""
|
|
29 |
||
30 |
||
11128.6.13
by Michael Hudson
add answers tests, remove last failing test_servers test |
31 |
class AnswersBrowserRequest(LaunchpadBrowserRequest): |
32 |
"""Instances of AnswersBrowserRequest provide `AnswersLayer`."""
|
|
11128.6.1
by Michael Hudson
move answers code out |
33 |
implements(AnswersLayer) |
34 |
||
35 |
def __init__(self, body_instream, environ, response=None): |
|
36 |
super(AnswersBrowserRequest, self).__init__( |
|
37 |
body_instream, environ, response) |
|
38 |
# Many of the responses from Answers vary based on language.
|
|
39 |
self.response.setHeader( |
|
40 |
'Vary', 'Cookie, Authorization, Accept-Language') |
|
41 |
||
42 |
||
43 |
def answers_request_publication_factory(): |
|
11128.6.13
by Michael Hudson
add answers tests, remove last failing test_servers test |
44 |
return VHostWebServiceRequestPublicationFactory( |
11128.6.1
by Michael Hudson
move answers code out |
45 |
'answers', AnswersBrowserRequest, LaunchpadBrowserPublication) |