Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
9c6c3e68422e
Commit
4b7b78fc
authored
Dec 08, 2015
by
Rémi Cardona
Browse files
[web/views] Controllers should always return bytes
Previous code breaks only on py3k.
parent
3f620fd1ed18
Changes
2
Hide whitespace changes
Inline
Side-by-side
web/test/unittest_views_basecontrollers.py
View file @
9c6c3e68
...
...
@@ -23,12 +23,12 @@ from six.moves.urllib.parse import urlsplit, urlunsplit, urljoin, parse_qs
import
lxml
from
logilab.common.testlib
import
unittest_main
from
logilab.common.decorators
import
monkeypatch
from
cubicweb
import
Binary
,
NoSelectableObject
,
ValidationError
from
cubicweb.schema
import
RRQLExpression
from
cubicweb.devtools.testlib
import
CubicWebTC
from
cubicweb.devtools.webtest
import
CubicWebTestTC
from
cubicweb.utils
import
json_dumps
from
cubicweb.uilib
import
rql_for_eid
from
cubicweb.web
import
Redirect
,
RemoteCallFailed
...
...
@@ -41,6 +41,19 @@ import cubicweb.transaction as tx
from
cubicweb.server.hook
import
Hook
,
Operation
from
cubicweb.predicates
import
is_instance
class
ViewControllerTC
(
CubicWebTestTC
):
def
test_view_ctrl_with_valid_cache_headers
(
self
):
resp
=
self
.
webapp
.
get
(
'/manage'
)
self
.
assertEqual
(
resp
.
etag
,
'manage/guests'
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
cache_headers
=
{
'if-modified-since'
:
resp
.
headers
[
'Last-Modified'
],
'if-none-match'
:
resp
.
etag
}
resp
=
self
.
webapp
.
get
(
'/manage'
,
headers
=
cache_headers
)
self
.
assertEqual
(
resp
.
status_code
,
304
)
self
.
assertEqual
(
len
(
resp
.
body
),
0
)
def
req_form
(
user
):
return
{
'eid'
:
[
str
(
user
.
eid
)],
'_cw_entity_fields:%s'
%
user
.
eid
:
'_cw_generic_field'
,
...
...
web/views/basecontrollers.py
View file @
9c6c3e68
...
...
@@ -128,7 +128,7 @@ class ViewController(Controller):
view
,
rset
=
self
.
_select_view_and_rset
(
rset
)
view
.
set_http_cache_headers
()
if
self
.
_cw
.
is_client_cache_valid
():
return
''
return
b
''
template
=
self
.
appli
.
main_template_id
(
self
.
_cw
)
return
self
.
_cw
.
vreg
[
'views'
].
main_template
(
self
.
_cw
,
template
,
rset
=
rset
,
view
=
view
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment