Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle ViewNotCallableError as 404 #1246

Merged
merged 7 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst
- Enable ZMI History tab for ``OFS.Image.File``.
(`#396 <https://github.com/zopefoundation/Zope/pull/396>`_)

- Fix error messages from spam/pen test requests.
- Fix requests from spam/pentests to return BadRequest/400 errors

- Fix a ``ResourceWarning`` emitted when uploading large files.
(`#1242 <https://github.com/zopefoundation/Zope/issues/1242>`_)
Expand Down
8 changes: 6 additions & 2 deletions src/ZPublisher/BaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,12 @@ def traverse(self, path, response=None, validated_hook=None):
# Zope2 doesn't set up its own adapters in a lot
# of cases so we will just use a default adapter.
adapter = DefaultPublishTraverse(object, self)

object, default_path = adapter.browserDefault(self)
try:
object, default_path = adapter.browserDefault(self)
except NotImplementedError:
return response.badRequestError(
"View is not callable. Traverse more."
djay marked this conversation as resolved.
Show resolved Hide resolved
)
if default_path:
request._hacked_path = 1
if len(default_path) > 1:
Expand Down
Loading