Skip to content

Commit

Permalink
Merge pull request #6 from zopefoundation/resurrection-python3
Browse files Browse the repository at this point in the history
Update Python 3 compatibility.
  • Loading branch information
janwijbrand committed Jan 10, 2018
2 parents d6d006d + 77c3ad2 commit 37cdec9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 14 deletions.
16 changes: 8 additions & 8 deletions .gitignore
@@ -1,13 +1,13 @@
bin/
eggs/
develop-eggs/
parts/
__pycache__/
.coverage
.installed.cfg
.mr.developer.cfg
.tox/
*.egg-info/
*.py[co]
__pycache__/
bin/
build/
develop-eggs/
dist/
*.egg-info/
.tox/
.coverage
htmlcov/
parts/
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -2,10 +2,11 @@ language: python
sudo: false
python:
- 2.7
- pypy-5.4.1
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
install:
- pip install -U pip setuptools
- pip install -U coverage coveralls
Expand Down
8 changes: 5 additions & 3 deletions CHANGES.rst
Expand Up @@ -5,8 +5,12 @@
1.0.1 (unreleased)
==================

- Nothing changed yet.
- Additional fixes for Python 3 compatibility.

NOTE: The error view base classes now set a Content-Type response header to
"text/plain". If your error view subclassing from the zope.errorview classes
return a response body other than "text/plain" you need to explicitly set
the Content-Type in your views.

1.0.0 (2017-05-10)
==================
Expand All @@ -15,13 +19,11 @@

- Fix typo in Dutch translation


0.11 (2011-06-28)
=================

- Added nl translations.


0.10 (2011-02-08)
=================

Expand Down
5 changes: 5 additions & 0 deletions buildout.cfg
Expand Up @@ -5,6 +5,11 @@ parts =
coverage-test
coverage-report
i18n
github = git://github.com/zopefoundation
github_push = git@github.com:zopefoundation

[versions]
z3c.recipe.i18n = >= 1.0.0

[test]
recipe = zc.recipe.testrunner
Expand Down
2 changes: 2 additions & 0 deletions src/zope/errorview/browser.py
Expand Up @@ -52,6 +52,8 @@ def update(self):
'Cache-Control', 'no-store, no-cache, must-revalidate')
self.request.response.setHeader(
'Pragma', 'no-cache')
self.request.response.setHeader(
'Content-Type', 'text/plain;charset=utf-8')
principal = self.request.principal
getUtility(IAuthentication).unauthorized(principal.id, self.request)

Expand Down
5 changes: 5 additions & 0 deletions src/zope/errorview/http.py
Expand Up @@ -40,6 +40,8 @@ def __init__(self, context, request):

def update(self):
self.request.response.setStatus(500)
self.request.response.setHeader(
'Content-Type', 'text/plain; charset=utf-8')

def render(self):
return ''
Expand All @@ -60,6 +62,7 @@ class ExceptionView(ExceptionViewBase):
class TraversalExceptionView(ExceptionViewBase):

def update(self):
super(TraversalExceptionView, self).update()
if self.request.method == 'MKCOL' and self.request.getTraversalStack():
# MKCOL with non-existing parent.
self.request.response.setStatus(409)
Expand All @@ -70,6 +73,7 @@ def update(self):
class UnauthorizedView(ExceptionViewBase):

def update(self):
super(UnauthorizedView, self).update()
self.request.unauthorized('basic realm="Zope"')
self.request.response.setStatus(401)

Expand All @@ -85,6 +89,7 @@ def allowed(self):
return []

def update(self):
super(MethodNotAllowedView, self).update()
allow = self.allowed()
self.request.response.setStatus(405)
self.request.response.setHeader('Allow', ', '.join(allow))
11 changes: 9 additions & 2 deletions tox.ini
@@ -1,9 +1,16 @@
[tox]
envlist =
py27, pypy, py34, py35, py36
py27,
py34,
py35,
py36,
pypy,
pypy3

[testenv]
commands =
zope-testrunner --test-path=src {posargs:-pv --auto-color}
coverage run -m zope.testrunner --test-path=src {posargs:-vc}
deps =
.[test]
zope.testrunner
coverage

0 comments on commit 37cdec9

Please sign in to comment.