author | Christophe de Vienne <christophe@unlish.com> |
Wed, 21 Jan 2015 15:13:43 +0100 | |
changeset 11545 | e83f90b1c900 |
parent 11539 | ff581d66f682 |
child 11575 | 97110b4af42f |
permissions | -rw-r--r-- |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
1 |
from pyramid import security |
11496
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
2 |
from pyramid import tweens |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
3 |
from pyramid.httpexceptions import HTTPSeeOther |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
4 |
from pyramid import httpexceptions |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
5 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
6 |
import cubicweb |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
7 |
import cubicweb.web |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
8 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
9 |
from cubicweb.web.application import CubicWebPublisher |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
10 |
|
11539 | 11 |
from cubicweb.web import LogOut |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
12 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
13 |
from pyramid_cubicweb.core import cw_to_pyramid |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
14 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
15 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
16 |
class PyramidSessionHandler(object): |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
17 |
"""A CW Session handler that rely on the pyramid API to fetch the needed |
11537
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
18 |
informations. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
19 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
20 |
It implements the :class:`cubicweb.web.application.CookieSessionHandler` |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
21 |
API. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
22 |
""" |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
23 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
24 |
def __init__(self, appli): |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
25 |
self.appli = appli |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
26 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
27 |
def get_session(self, req): |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
28 |
return req._request.cw_session |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
29 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
30 |
def logout(self, req, goto_url): |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
31 |
raise LogOut(url=goto_url) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
32 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
33 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
34 |
class CubicWebPyramidHandler(object): |
11537
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
35 |
""" A Pyramid request handler that rely on a cubicweb instance to do the |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
36 |
whole job |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
37 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
38 |
:param appli: A CubicWeb 'Application' object. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
39 |
""" |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
40 |
def __init__(self, appli): |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
41 |
self.appli = appli |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
42 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
43 |
def __call__(self, request): |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
44 |
""" |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
45 |
Handler that mimics what CubicWebPublisher.main_handle_request and |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
46 |
CubicWebPublisher.core_handle do |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
47 |
""" |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
48 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
49 |
# XXX The main handler of CW forbid anonymous https connections |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
50 |
# I guess we can drop this "feature" but in doubt I leave this comment |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
51 |
# so we don't forget about it. (cdevienne) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
52 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
53 |
req = request.cw_request |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
54 |
vreg = request.registry['cubicweb.registry'] |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
55 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
56 |
try: |
11511
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11505
diff
changeset
|
57 |
content = None |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
58 |
try: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
59 |
with cw_to_pyramid(request): |
11539 | 60 |
ctrlid, rset = self.appli.url_resolver.process(req, |
61 |
req.path) |
|
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
62 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
63 |
try: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
64 |
controller = vreg['controllers'].select( |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
65 |
ctrlid, req, appli=self.appli) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
66 |
except cubicweb.NoSelectableObject: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
67 |
raise httpexceptions.HTTPUnauthorized( |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
68 |
req._('not authorized')) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
69 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
70 |
req.update_search_state() |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
71 |
content = controller.publish(rset=rset) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
72 |
|
11539 | 73 |
# XXX this auto-commit should be handled by the cw_request |
74 |
# cleanup or the pyramid transaction manager. |
|
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
75 |
# It is kept here to have the ValidationError handling bw |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
76 |
# compatible |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
77 |
if req.cnx: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
78 |
txuuid = req.cnx.commit() |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
79 |
# commited = True |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
80 |
if txuuid is not None: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
81 |
req.data['last_undoable_transaction'] = txuuid |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
82 |
except cubicweb.web.ValidationError as ex: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
83 |
# XXX The validation_error_handler implementation is light, we |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
84 |
# should redo it better in cw_to_pyramid, so it can be properly |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
85 |
# handled when raised from a cubicweb view. |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
86 |
# BUT the real handling of validation errors should be done |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
87 |
# earlier in the controllers, not here. In the end, the |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
88 |
# ValidationError should never by handled here. |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
89 |
content = self.appli.validation_error_handler(req, ex) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
90 |
except cubicweb.web.RemoteCallFailed as ex: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
91 |
# XXX The default pyramid error handler (or one that we provide |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
92 |
# for this exception) should be enough |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
93 |
# content = self.appli.ajax_error_handler(req, ex) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
94 |
raise |
11499
60a504740951
Convert cubicweb.NotFound to HTTPNotFound
Christophe de Vienne <christophe@unlish.com>
parents:
11496
diff
changeset
|
95 |
except cubicweb.web.NotFound as ex: |
60a504740951
Convert cubicweb.NotFound to HTTPNotFound
Christophe de Vienne <christophe@unlish.com>
parents:
11496
diff
changeset
|
96 |
raise httpexceptions.HTTPNotFound(ex.message) |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
97 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
98 |
if content is not None: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
99 |
request.response.body = content |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
100 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
101 |
# XXX CubicWebPyramidRequest.headers_out should |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
102 |
# access directly the pyramid response headers. |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
103 |
request.response.headers.clear() |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
104 |
for k, v in req.headers_out.getAllRawHeaders(): |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
105 |
for item in v: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
106 |
request.response.headers.add(k, item) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
107 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
108 |
except LogOut as ex: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
109 |
# The actual 'logging out' logic should be in separated function |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
110 |
# that is accessible by the pyramid views |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
111 |
headers = security.forget(request) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
112 |
raise HTTPSeeOther(ex.url, headers=headers) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
113 |
# except AuthenticationError: |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
114 |
# XXX I don't think it makes sens to catch this ex here (cdevienne) |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
115 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
116 |
return request.response |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
117 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
118 |
|
11496
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
119 |
class TweenHandler(object): |
11537
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
120 |
""" A Pyramid tween handler that submit unhandled requests to a Cubicweb |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
121 |
handler. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
122 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
123 |
The CubicWeb handler to use is expected to be in the pyramid registry, at |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
124 |
key ``'cubicweb.handler'``. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
125 |
""" |
11496
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
126 |
def __init__(self, handler, registry): |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
127 |
self.handler = handler |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
128 |
self.cwhandler = registry['cubicweb.handler'] |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
129 |
|
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
130 |
def __call__(self, request): |
11505
eca6387f5b87
Handle properly the '/https/*' urls
Christophe de Vienne <christophe@unlish.com>
parents:
11499
diff
changeset
|
131 |
if request.path.startswith('/https/'): |
eca6387f5b87
Handle properly the '/https/*' urls
Christophe de Vienne <christophe@unlish.com>
parents:
11499
diff
changeset
|
132 |
request.environ['PATH_INFO'] = request.environ['PATH_INFO'][6:] |
eca6387f5b87
Handle properly the '/https/*' urls
Christophe de Vienne <christophe@unlish.com>
parents:
11499
diff
changeset
|
133 |
assert not request.path.startswith('/https/') |
eca6387f5b87
Handle properly the '/https/*' urls
Christophe de Vienne <christophe@unlish.com>
parents:
11499
diff
changeset
|
134 |
request.scheme = 'https' |
11496
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
135 |
try: |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
136 |
response = self.handler(request) |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
137 |
except httpexceptions.HTTPNotFound: |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
138 |
response = self.cwhandler(request) |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
139 |
return response |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
140 |
|
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
141 |
|
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
142 |
def includeme(config): |
11537
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
143 |
""" Set up a tween app that will handle the request if the main application |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
144 |
raises a HTTPNotFound exception. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
145 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
146 |
This is to keep legacy compatibility for cubes that makes use of the |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
147 |
cubicweb urlresolvers. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
148 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
149 |
It provides, for now, support for cubicweb controllers, but this feature |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
150 |
will be reimplemented separatly in a less compatible way. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
151 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
152 |
It is automatically included by the configuration system, but can be |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
153 |
disabled in the :ref:`pyramid_settings`: |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
154 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
155 |
.. code-block:: ini |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
156 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
157 |
cubicweb.bwcompat = no |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
158 |
""" |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
159 |
cwconfig = config.registry['cubicweb.config'] |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
160 |
repository = config.registry['cubicweb.repository'] |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
161 |
cwappli = CubicWebPublisher( |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
162 |
repository, cwconfig, |
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
163 |
session_handler_fact=PyramidSessionHandler) |
11496
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
164 |
cwhandler = CubicWebPyramidHandler(cwappli) |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
165 |
|
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
166 |
config.registry['cubicweb.appli'] = cwappli |
11496
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
167 |
config.registry['cubicweb.handler'] = cwhandler |
11492
b0b8942cdb80
Separate into 4 modules
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
168 |
|
11496
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
169 |
config.add_tween( |
500615e26063
Use a tween application instead of a catchall route.
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
170 |
'pyramid_cubicweb.bwcompat.TweenHandler', under=tweens.EXCVIEW) |