zope.app.http 4.0.1__tar.gz → 6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. zope_app_http-6.0/.pre-commit-config.yaml +28 -0
  2. {zope.app.http-4.0.1 → zope_app_http-6.0}/CHANGES.txt +19 -0
  3. zope_app_http-6.0/CONTRIBUTING.md +23 -0
  4. zope_app_http-6.0/MANIFEST.in +11 -0
  5. zope_app_http-6.0/PKG-INFO +226 -0
  6. zope_app_http-6.0/buildout.cfg +7 -0
  7. zope_app_http-6.0/pyproject.toml +32 -0
  8. zope_app_http-6.0/setup.cfg +23 -0
  9. {zope.app.http-4.0.1 → zope_app_http-6.0}/setup.py +36 -32
  10. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/delete.py +1 -1
  11. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/methodnotallowed.py +3 -3
  12. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/notfound.py +4 -3
  13. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/tests/test_methodnotallowed.py +33 -36
  14. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/tests/test_unauthorized.py +9 -12
  15. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/unauthorized.py +3 -2
  16. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/httpdate.py +64 -53
  17. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/interfaces.py +4 -5
  18. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/options.py +8 -7
  19. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/put.py +11 -9
  20. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/tests/test_delete.py +10 -14
  21. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/tests/test_options.py +4 -10
  22. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/tests/test_put.py +20 -24
  23. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/tests/test_traversers.py +11 -17
  24. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/traversal.py +9 -5
  25. zope_app_http-6.0/src/zope.app.http.egg-info/PKG-INFO +226 -0
  26. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope.app.http.egg-info/SOURCES.txt +3 -4
  27. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope.app.http.egg-info/requires.txt +5 -4
  28. zope_app_http-6.0/tox.ini +71 -0
  29. zope.app.http-4.0.1/MANIFEST.in +0 -5
  30. zope.app.http-4.0.1/PKG-INFO +0 -181
  31. zope.app.http-4.0.1/bootstrap.py +0 -210
  32. zope.app.http-4.0.1/buildout.cfg +0 -18
  33. zope.app.http-4.0.1/setup.cfg +0 -7
  34. zope.app.http-4.0.1/src/zope/__init__.py +0 -8
  35. zope.app.http-4.0.1/src/zope/app/__init__.py +0 -8
  36. zope.app.http-4.0.1/src/zope.app.http.egg-info/PKG-INFO +0 -181
  37. zope.app.http-4.0.1/src/zope.app.http.egg-info/namespace_packages.txt +0 -2
  38. zope.app.http-4.0.1/tox.ini +0 -12
  39. {zope.app.http-4.0.1 → zope_app_http-6.0}/COPYRIGHT.txt +0 -0
  40. {zope.app.http-4.0.1 → zope_app_http-6.0}/LICENSE.txt +0 -0
  41. {zope.app.http-4.0.1 → zope_app_http-6.0}/README.txt +0 -0
  42. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/__init__.py +0 -0
  43. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/configure.zcml +0 -0
  44. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/__init__.py +0 -0
  45. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/configure.zcml +0 -0
  46. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/exception/tests/__init__.py +0 -0
  47. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/ftesting.zcml +0 -0
  48. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope/app/http/tests/__init__.py +0 -0
  49. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope.app.http.egg-info/dependency_links.txt +0 -0
  50. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope.app.http.egg-info/not-zip-safe +0 -0
  51. {zope.app.http-4.0.1 → zope_app_http-6.0}/src/zope.app.http.egg-info/top_level.txt +0 -0
@@ -0,0 +1,28 @@
1
+ # Generated from:
2
+ # https://github.com/zopefoundation/meta/tree/master/config/pure-python
3
+ minimum_pre_commit_version: '3.6'
4
+ repos:
5
+ - repo: https://github.com/pycqa/isort
6
+ rev: "6.0.1"
7
+ hooks:
8
+ - id: isort
9
+ - repo: https://github.com/hhatto/autopep8
10
+ rev: "v2.3.2"
11
+ hooks:
12
+ - id: autopep8
13
+ args: [--in-place, --aggressive, --aggressive]
14
+ - repo: https://github.com/asottile/pyupgrade
15
+ rev: v3.20.0
16
+ hooks:
17
+ - id: pyupgrade
18
+ args: [--py39-plus]
19
+ - repo: https://github.com/isidentical/teyit
20
+ rev: 0.4.3
21
+ hooks:
22
+ - id: teyit
23
+ - repo: https://github.com/PyCQA/flake8
24
+ rev: "7.3.0"
25
+ hooks:
26
+ - id: flake8
27
+ additional_dependencies:
28
+ - flake8-debugger == 4.1.2
@@ -2,6 +2,24 @@
2
2
  CHANGES
3
3
  =======
4
4
 
5
+ 6.0 (2025-09-12)
6
+ ----------------
7
+
8
+ - Replace ``pkg_resources`` namespace with PEP 420 native namespace.
9
+
10
+ - Add support for Python 3.12, 3.13.
11
+
12
+ - Drop support for Python 3.7, 3.8.
13
+
14
+
15
+ 5.0 (2023-02-07)
16
+ ----------------
17
+
18
+ - Drop support for Python 2.7, 3.3, 3.4, 3.5, 3.6.
19
+
20
+ - Add support for Python 3.7, 3.8 and 3.9.
21
+
22
+
5
23
  4.0.1 (2017-05-16)
6
24
  ------------------
7
25
 
@@ -17,6 +35,7 @@ CHANGES
17
35
 
18
36
  - Added support for PyPy2.
19
37
 
38
+
20
39
  3.10.2 (2011-08-09)
21
40
  -------------------
22
41
 
@@ -0,0 +1,23 @@
1
+ <!--
2
+ Generated from:
3
+ https://github.com/zopefoundation/meta/tree/master/config/pure-python
4
+ -->
5
+ # Contributing to zopefoundation projects
6
+
7
+ The projects under the zopefoundation GitHub organization are open source and
8
+ welcome contributions in different forms:
9
+
10
+ * bug reports
11
+ * code improvements and bug fixes
12
+ * documentation improvements
13
+ * pull request reviews
14
+
15
+ For any changes in the repository besides trivial typo fixes you are required
16
+ to sign the contributor agreement. See
17
+ https://www.zope.dev/developer/becoming-a-committer.html for details.
18
+
19
+ Please visit our [Developer
20
+ Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to
21
+ contribute code changes and our [guidelines for reporting
22
+ bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a
23
+ bug report.
@@ -0,0 +1,11 @@
1
+ # Generated from:
2
+ # https://github.com/zopefoundation/meta/tree/master/config/pure-python
3
+ include *.md
4
+ include *.rst
5
+ include *.txt
6
+ include buildout.cfg
7
+ include tox.ini
8
+ include .pre-commit-config.yaml
9
+
10
+ recursive-include src *.py
11
+ recursive-include src *.zcml
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: zope.app.http
3
+ Version: 6.0
4
+ Summary: HTTP Behavior for the Zope Publisher
5
+ Home-page: https://github.com/zopefoundation/zope.app.http
6
+ Author: Zope Foundation and Contributors
7
+ Author-email: zope-dev@zope.dev
8
+ License: ZPL-2.1
9
+ Keywords: zope3 http publisher view
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Web Environment
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Zope Public License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: Implementation
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
23
+ Classifier: Natural Language :: English
24
+ Classifier: Operating System :: OS Independent
25
+ Classifier: Topic :: Internet :: WWW/HTTP
26
+ Classifier: Framework :: Zope :: 3
27
+ Requires-Python: >=3.9
28
+ License-File: LICENSE.txt
29
+ Requires-Dist: setuptools
30
+ Requires-Dist: zope.interface
31
+ Requires-Dist: zope.publisher>=4.0.0a2
32
+ Requires-Dist: zope.container>=4.0.0a2
33
+ Requires-Dist: zope.filerepresentation
34
+ Provides-Extra: test
35
+ Requires-Dist: zope.app.wsgi[testlayer]>=4.0; extra == "test"
36
+ Requires-Dist: zope.browserpage; extra == "test"
37
+ Requires-Dist: zope.component; extra == "test"
38
+ Requires-Dist: zope.login; extra == "test"
39
+ Requires-Dist: zope.password; extra == "test"
40
+ Requires-Dist: zope.principalregistry; extra == "test"
41
+ Requires-Dist: zope.securitypolicy>=4.0.0a1; extra == "test"
42
+ Requires-Dist: zope.site>=4.0.0a1; extra == "test"
43
+ Requires-Dist: zope.testrunner>=6.4; extra == "test"
44
+ Dynamic: author
45
+ Dynamic: author-email
46
+ Dynamic: classifier
47
+ Dynamic: description
48
+ Dynamic: home-page
49
+ Dynamic: keywords
50
+ Dynamic: license
51
+ Dynamic: license-file
52
+ Dynamic: provides-extra
53
+ Dynamic: requires-dist
54
+ Dynamic: requires-python
55
+ Dynamic: summary
56
+
57
+ zope.app.http
58
+ *************
59
+
60
+ This package implements the simplest HTTP behavior within the Zope
61
+ Publisher. It implements all HTTP verbs as views and defines the necessary
62
+ HTTP exceptions.
63
+
64
+
65
+ =======
66
+ CHANGES
67
+ =======
68
+
69
+ 6.0 (2025-09-12)
70
+ ----------------
71
+
72
+ - Replace ``pkg_resources`` namespace with PEP 420 native namespace.
73
+
74
+ - Add support for Python 3.12, 3.13.
75
+
76
+ - Drop support for Python 3.7, 3.8.
77
+
78
+
79
+ 5.0 (2023-02-07)
80
+ ----------------
81
+
82
+ - Drop support for Python 2.7, 3.3, 3.4, 3.5, 3.6.
83
+
84
+ - Add support for Python 3.7, 3.8 and 3.9.
85
+
86
+
87
+ 4.0.1 (2017-05-16)
88
+ ------------------
89
+
90
+ - The PUT views return an empty byte string instead of an empty native
91
+ string. On Python 3, the unicode native string leads to a TypeError
92
+ in zope.publisher.http.
93
+
94
+
95
+ 4.0.0 (2016-08-08)
96
+ ------------------
97
+
98
+ - Added support for Python 3.3 up to 3.6.
99
+
100
+ - Added support for PyPy2.
101
+
102
+
103
+ 3.10.2 (2011-08-09)
104
+ -------------------
105
+
106
+ - Fixing brown bag release 3.10.1, failing tests.
107
+
108
+
109
+ 3.10.1 (2011-08-04)
110
+ -------------------
111
+
112
+ - Replaced an undeclared test dependency on ``zope.app.authentication`` with
113
+ ``zope.password``.
114
+
115
+ - Replaced the testing dependency on ``zope.app.zcmlfiles`` with explicit
116
+ dependencies of a minimal set of packages.
117
+
118
+
119
+ 3.10.0 (2011-01-25)
120
+ -------------------
121
+
122
+ - PUT raises ``405 MethodNotAllowed`` when the context cannot be adapted to
123
+ ``zope.filerepresentation.interfaces.IWriteFile`` for existing objects
124
+ resp. ``zope.filerepresentation.interfaces.IFileFactory`` for not existing
125
+ ones.
126
+
127
+
128
+ 3.9.0 (2010-09-17)
129
+ ------------------
130
+
131
+ - Replaced a testing dependency on `zope.app.securitypolicy` with one on
132
+ `zope.securitypolicy`.
133
+
134
+ - Removed test dependency on `zope.app.file` by moving the test which needs
135
+ this package to `zope.app.file`.
136
+
137
+
138
+ 3.8 (2010-04-19)
139
+ ----------------
140
+
141
+ - Remove dependency on `zope.app.testing` by using the
142
+ `zope.app.wsgi.testlayer` support instead.
143
+
144
+ At the time of this writing the test dependency on
145
+ `zope.app.zcmlfiles` cannot be removed however, because there is a
146
+ dependency on `zope.app.file` for testing, which pulls in the world.
147
+
148
+ 3.7 (2010-04-13)
149
+ ----------------
150
+
151
+ - Remove unnecessary dependency on `zope.app.publisher`.
152
+
153
+ - Fix for an edge case:
154
+ If someone does a ``defaultView`` for the context object and someone comes with
155
+ a not allowed method, the exception view fails on ``getAdapters``.
156
+
157
+ 3.6.1 (2010-01-08)
158
+ ------------------
159
+
160
+ - Replaced the dependency on `zope.deprecation` with BBB imports
161
+
162
+ - Made the dependency on `zope.app.publisher` explicit
163
+
164
+ - Fix tests using a newer `zope.publisher` that requires `zope.login`.
165
+
166
+ 3.6.0 (2009-05-23)
167
+ ------------------
168
+
169
+ - Moved ``IHTTPException``, ``IMethodNotAllowed``, and ``MethodNotAllowed`` from
170
+ `zope.app.http` to `zope.publisher.interfaces.http`, fixing dependency
171
+ cycles involving `zope.app.http`.
172
+
173
+ 3.5.2 (2009-04-01)
174
+ ------------------
175
+
176
+ - Replaced deprecated ``zope:defaultView`` directive with
177
+ ``browser:defaultView``.
178
+
179
+ 3.5.1 (2009-03-12)
180
+ ------------------
181
+
182
+ - If the 'CONTENT_LENGTH' header is provided, provide this length as
183
+ argument to the ``read`` method of the input stream object.
184
+
185
+ 3.5.0 (2009-02-01)
186
+ ------------------
187
+
188
+ - Change dependency on `zope.app.container` to `zope.container`.
189
+
190
+ 3.4.5 (2010-01-28)
191
+ ------------------
192
+
193
+ - Backport r108613 from trunk:
194
+ Fix for an edge case:
195
+ If someone does a ``defaultView`` for the context object and someone comes with
196
+ a not allowed method, the exception view fails on ``getAdapters``.
197
+
198
+ 3.4.4 (2009-01-29)
199
+ ------------------
200
+
201
+ - Make tests compatible with new `zope.traversing` release.
202
+
203
+ 3.4.3 (2009-01-27)
204
+ ------------------
205
+
206
+ - Added missing depencendy: `zope.app.zcmlfiles`.
207
+
208
+ 3.4.2 (2009-01-26)
209
+ ------------------
210
+
211
+ - Add a couple of tests to the OPTIONS verb.
212
+
213
+ - Substitute `zope.app.zapi` by direct calls to its wrapped APIs and get
214
+ rid of `zope.app.zapi` as a dependency. See bug #LP219302.
215
+
216
+
217
+ 3.4.1 (2007-10-31)
218
+ ------------------
219
+
220
+ - Resolved ``ZopeSecurityPolicy`` deprecation warning.
221
+
222
+
223
+ 3.4.0 (2007-10-24)
224
+ ------------------
225
+
226
+ - Initial release independent of the main Zope tree.
@@ -0,0 +1,7 @@
1
+ [buildout]
2
+ develop = .
3
+ parts = test
4
+
5
+ [test]
6
+ recipe = zc.recipe.testrunner
7
+ eggs = zope.app.http[test]
@@ -0,0 +1,32 @@
1
+ # Generated from:
2
+ # https://github.com/zopefoundation/meta/tree/master/config/pure-python
3
+
4
+ [build-system]
5
+ requires = [
6
+ "setuptools == 78.1.1",
7
+ "wheel",
8
+ ]
9
+ build-backend = "setuptools.build_meta"
10
+
11
+ [tool.coverage.run]
12
+ branch = true
13
+ source = ["zope.app.http"]
14
+
15
+ [tool.coverage.report]
16
+ fail_under = 84
17
+ precision = 2
18
+ ignore_errors = true
19
+ show_missing = true
20
+ exclude_lines = [
21
+ "pragma: no cover",
22
+ "pragma: nocover",
23
+ "except ImportError:",
24
+ "raise NotImplementedError",
25
+ "if __name__ == '__main__':",
26
+ "self.fail",
27
+ "raise AssertionError",
28
+ "raise unittest.Skip",
29
+ ]
30
+
31
+ [tool.coverage.html]
32
+ directory = "parts/htmlcov"
@@ -0,0 +1,23 @@
1
+ [flake8]
2
+ doctests = 1
3
+
4
+ [check-manifest]
5
+ ignore =
6
+ .editorconfig
7
+ .meta.toml
8
+
9
+ [isort]
10
+ force_single_line = True
11
+ combine_as_imports = True
12
+ sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
13
+ known_third_party = docutils, pkg_resources, pytz
14
+ known_zope =
15
+ known_first_party =
16
+ default_section = ZOPE
17
+ line_length = 79
18
+ lines_after_imports = 2
19
+
20
+ [egg_info]
21
+ tag_build =
22
+ tag_date = 0
23
+
@@ -12,69 +12,73 @@
12
12
  #
13
13
  ##############################################################################
14
14
  # This package is developed by the Zope Toolkit project, documented here:
15
- # http://docs.zope.org/zopetoolkit
15
+ # https://zopetoolkit.readthedocs.io/en/latest/
16
16
  # When developing and releasing this package, please follow the documented
17
17
  # Zope Toolkit policies as described by this documentation.
18
18
  ##############################################################################
19
19
  """Setup for zope.app.http package
20
20
  """
21
21
  import os
22
- from setuptools import setup, find_packages
22
+
23
+ from setuptools import setup
24
+
23
25
 
24
26
  def read(*rnames):
25
27
  return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
26
28
 
29
+
27
30
  setup(name='zope.app.http',
28
- version='4.0.1',
29
- author='Zope Corporation and Contributors',
30
- author_email='zope-dev@zope.org',
31
+ version='6.0',
32
+ author='Zope Foundation and Contributors',
33
+ author_email='zope-dev@zope.dev',
31
34
  description='HTTP Behavior for the Zope Publisher',
32
35
  long_description=(
33
36
  read('README.txt')
34
37
  + '\n\n' +
35
38
  read('CHANGES.txt')
36
- ),
39
+ ),
37
40
  keywords="zope3 http publisher view",
38
41
  classifiers=[
39
42
  'Development Status :: 5 - Production/Stable',
40
43
  'Environment :: Web Environment',
41
44
  'Intended Audience :: Developers',
42
45
  'License :: OSI Approved :: Zope Public License',
43
- 'Programming Language :: Python :: 2',
44
- 'Programming Language :: Python :: 2.6',
45
- 'Programming Language :: Python :: 2.7',
46
46
  'Programming Language :: Python :: 3',
47
- 'Programming Language :: Python :: 3.3',
48
- 'Programming Language :: Python :: 3.4',
49
- 'Programming Language :: Python :: 3.5',
50
- 'Programming Language :: Python :: 3.6',
47
+ 'Programming Language :: Python :: 3.9',
48
+ 'Programming Language :: Python :: 3.10',
49
+ 'Programming Language :: Python :: 3.11',
50
+ 'Programming Language :: Python :: 3.12',
51
+ 'Programming Language :: Python :: 3.13',
51
52
  'Programming Language :: Python :: Implementation',
52
53
  'Programming Language :: Python :: Implementation :: CPython',
53
54
  'Programming Language :: Python :: Implementation :: PyPy',
54
55
  'Natural Language :: English',
55
56
  'Operating System :: OS Independent',
56
57
  'Topic :: Internet :: WWW/HTTP',
57
- 'Framework :: Zope3'],
58
+ 'Framework :: Zope :: 3',
59
+ ],
58
60
  url='https://github.com/zopefoundation/zope.app.http',
59
- license='ZPL 2.1',
60
- packages=find_packages('src'),
61
- package_dir={'': 'src'},
62
- namespace_packages=['zope', 'zope.app'],
61
+ license='ZPL-2.1',
62
+ python_requires='>=3.9',
63
63
  extras_require=dict(
64
- test=['zope.app.wsgi[testlayer] >= 4.0',
65
- 'zope.browserpage',
66
- 'zope.component',
67
- 'zope.login',
68
- 'zope.password',
69
- 'zope.principalregistry',
70
- 'zope.securitypolicy >= 4.0.0a1',
71
- 'zope.site >= 4.0.0a1']),
72
- install_requires=['setuptools',
73
- 'zope.interface',
74
- 'zope.publisher>=4.0.0a2',
75
- 'zope.container >= 4.0.0a2',
76
- 'zope.filerepresentation',
77
- ],
64
+ test=[
65
+ 'zope.app.wsgi[testlayer] >= 4.0',
66
+ 'zope.browserpage',
67
+ 'zope.component',
68
+ 'zope.login',
69
+ 'zope.password',
70
+ 'zope.principalregistry',
71
+ 'zope.securitypolicy >= 4.0.0a1',
72
+ 'zope.site >= 4.0.0a1',
73
+ 'zope.testrunner >= 6.4',
74
+ ]),
75
+ install_requires=[
76
+ 'setuptools',
77
+ 'zope.interface',
78
+ 'zope.publisher>=4.0.0a2',
79
+ 'zope.container >= 4.0.0a2',
80
+ 'zope.filerepresentation',
81
+ ],
78
82
  include_package_data=True,
79
83
  zip_safe=False,
80
84
  )
@@ -17,7 +17,7 @@ from zope.filerepresentation.interfaces import IWriteDirectory
17
17
  from zope.publisher.interfaces.http import MethodNotAllowed
18
18
 
19
19
 
20
- class DELETE(object):
20
+ class DELETE:
21
21
  """Delete handler for all objects
22
22
  """
23
23
 
@@ -16,7 +16,7 @@ from zope.interface import Interface
16
16
  from zope.publisher.interfaces.http import IMethodNotAllowed
17
17
 
18
18
 
19
- class MethodNotAllowedView(object):
19
+ class MethodNotAllowedView:
20
20
  """A view for MethodNotAllowed that renders a HTTP 405 response."""
21
21
 
22
22
  __used_for__ = IMethodNotAllowed
@@ -24,10 +24,10 @@ class MethodNotAllowedView(object):
24
24
  def __init__(self, error, request):
25
25
  self.error = error
26
26
  self.request = request
27
- allow = []
28
27
 
29
28
  try:
30
- # see test_methodnotallowed.TestMethodNotAllowedView.test_defaultView
29
+ # see
30
+ # test_methodnotallowed.TestMethodNotAllowedView.test_defaultView
31
31
  # I could not solve this with a while ... next() iterator
32
32
  # because it seems like once the generator had an exception it
33
33
  # stops returning items
@@ -15,11 +15,12 @@
15
15
  """
16
16
  __docformat__ = 'restructuredtext'
17
17
 
18
- from zope.publisher.interfaces.http import IHTTPException
19
18
  from zope.interface import implementer
19
+ from zope.publisher.interfaces.http import IHTTPException
20
+
20
21
 
21
22
  @implementer(IHTTPException)
22
- class NotFound(object):
23
+ class NotFound:
23
24
 
24
25
  def __init__(self, context, request):
25
26
  self.context = context
@@ -27,7 +28,7 @@ class NotFound(object):
27
28
 
28
29
  def __call__(self):
29
30
  if self.request.method in ['MKCOL'] and \
30
- self.request.getTraversalStack():
31
+ self.request.getTraversalStack():
31
32
  # MKCOL with non-existing parent.
32
33
  self.request.response.setStatus(409)
33
34
  else:
@@ -13,35 +13,37 @@
13
13
  ##############################################################################
14
14
  """Tests for HTTP error views
15
15
  """
16
- from unittest import TestCase, TestSuite, main, makeSuite
17
16
  from io import BytesIO
17
+ from unittest import TestCase
18
18
 
19
- from zope.interface import Interface, implementer
19
+ from zope.component import provideAdapter
20
+ from zope.interface import Interface
21
+ from zope.interface import implementer
20
22
  from zope.publisher.http import HTTPRequest
21
23
  from zope.publisher.interfaces.http import IHTTPRequest
22
24
 
23
- from zope.component import provideAdapter
24
-
25
25
 
26
- class I(Interface):
26
+ class Iface(Interface):
27
27
  pass
28
28
 
29
29
 
30
- @implementer(I)
31
- class C(object):
30
+ @implementer(Iface)
31
+ class C:
32
32
  pass
33
33
 
34
34
 
35
- class GetView(object):
35
+ class GetView:
36
36
  def __init__(self, context, request):
37
37
  pass
38
+
38
39
  def GET(self):
39
40
  pass
40
41
 
41
42
 
42
- class DeleteView(object):
43
+ class DeleteView:
43
44
  def __init__(self, context, request):
44
45
  pass
46
+
45
47
  def DELETE(self):
46
48
  pass
47
49
 
@@ -49,25 +51,29 @@ class DeleteView(object):
49
51
  class TestMethodNotAllowedView(TestCase):
50
52
 
51
53
  def setUp(self):
52
- provideAdapter(GetView, (I, IHTTPRequest), Interface, 'GET')
53
- provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'DELETE')
54
- provideAdapter(GetView, (I, IHTTPRequest), Interface, 'irrelevant')
55
- provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'also_irr.')
56
-
54
+ provideAdapter(GetView, (Iface, IHTTPRequest), Interface, 'GET')
55
+ provideAdapter(DeleteView, (Iface, IHTTPRequest), Interface, 'DELETE')
56
+ provideAdapter(GetView, (Iface, IHTTPRequest), Interface, 'irrelevant')
57
+ provideAdapter(
58
+ DeleteView, (Iface, IHTTPRequest), Interface, 'also_irrelevant')
59
+
57
60
  from zope.publisher.interfaces import IDefaultViewName
58
61
  from zope.publisher.interfaces.browser import IBrowserRequest
59
- #do the same as defaultView would for something like:
60
- #<defaultView
62
+
63
+ # do the same as defaultView would for something like:
64
+ # <defaultView
61
65
  # for=".test_methodnotallowed.I"
62
66
  # name="index.html"
63
67
  # />
64
68
 
65
- provideAdapter(u'index.html', (I, IBrowserRequest), IDefaultViewName)
66
-
69
+ provideAdapter(
70
+ 'index.html', (Iface, IBrowserRequest), IDefaultViewName)
71
+
67
72
  def test(self):
68
73
  from zope.publisher.interfaces.http import MethodNotAllowed
69
- from zope.app.http.exception.methodnotallowed \
70
- import MethodNotAllowedView
74
+
75
+ from zope.app.http.exception.methodnotallowed import \
76
+ MethodNotAllowedView
71
77
 
72
78
  context = C()
73
79
  request = HTTPRequest(BytesIO(b'PUT /bla/bla HTTP/1.1\n\n'), {})
@@ -80,20 +86,20 @@ class TestMethodNotAllowedView(TestCase):
80
86
  self.assertEqual(request.response.getHeader('Allow'), 'DELETE, GET')
81
87
  self.assertEqual(result, b'Method Not Allowed')
82
88
 
83
-
84
89
  def test_defaultView(self):
85
90
  # do the same with a BrowserRequest
86
- # edge case is that if someone does a defaultView for the context object
87
- # but the app is not prepared for webdav or whatever
91
+ # edge case is that if someone does a defaultView for the context
92
+ # object but the app is not prepared for webdav or whatever
88
93
  # and someone comes with a not allowed method, the exception
89
94
  # view fails on getAdapters
90
95
  # this might be an issue with zope.publisher, as it provides
91
96
  # a unicode object with provideAdapter, but I don't think I can
92
97
  # change zope.publisher
93
- from zope.publisher.interfaces.http import MethodNotAllowed
94
- from zope.app.http.exception.methodnotallowed \
95
- import MethodNotAllowedView
96
98
  from zope.publisher.browser import BrowserRequest
99
+ from zope.publisher.interfaces.http import MethodNotAllowed
100
+
101
+ from zope.app.http.exception.methodnotallowed import \
102
+ MethodNotAllowedView
97
103
 
98
104
  context = C()
99
105
  request = BrowserRequest(BytesIO(b'PUT /bla/bla HTTP/1.1\n\n'), {})
@@ -104,15 +110,6 @@ class TestMethodNotAllowedView(TestCase):
104
110
  result = view()
105
111
 
106
112
  self.assertEqual(request.response.getStatus(), 405)
107
- #well this is empty, but we're grateful that it does not break
113
+ # well this is empty, but we're grateful that it does not break
108
114
  self.assertEqual(request.response.getHeader('Allow'), '')
109
115
  self.assertEqual(result, b'Method Not Allowed')
110
-
111
-
112
- def test_suite():
113
- return TestSuite((
114
- makeSuite(TestMethodNotAllowedView),
115
- ))
116
-
117
- if __name__=='__main__':
118
- main(defaultTest='test_suite')