Skip to content

Commit

Permalink
handle ViewNotCallableError as BadRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
djay committed Jan 15, 2025
1 parent fbd6ce9 commit a4ee71d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ZPublisher/BaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from ExtensionClass import Base
from zExceptions import Forbidden
from zExceptions import NotFound
from zope.publisher.interfaces import ViewNotCallableError
from zope.component import queryMultiAdapter
from zope.event import notify
from zope.interface import Interface
Expand Down Expand Up @@ -469,8 +470,10 @@ 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 ViewNotCallableError:
return response.badRequestError("View is not callable so likely is missing additional path elements")
if default_path:
request._hacked_path = 1
if len(default_path) > 1:
Expand Down

0 comments on commit a4ee71d

Please sign in to comment.