Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
836f07cf
Commit
836f07cf
authored
Oct 06, 2004
by
Sidnei da Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove fallback on __bobo_traverse__ failure, as discussed with Chris McDonough.
parent
aa87b334
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
43 deletions
+10
-43
lib/python/ZPublisher/BaseRequest.py
lib/python/ZPublisher/BaseRequest.py
+9
-8
lib/python/ZPublisher/tests/testBaseRequest.py
lib/python/ZPublisher/tests/testBaseRequest.py
+1
-35
No files found.
lib/python/ZPublisher/BaseRequest.py
View file @
836f07cf
...
...
@@ -308,19 +308,20 @@ class BaseRequest:
"Object name begins with an underscore at: %s"
%
URL
)
else
:
return
response
.
forbiddenError
(
entry_name
)
bobo_got
=
0
try
:
if
hasattr
(
object
,
'__bobo_traverse__'
):
try
:
subobject
=
object
.
__bobo_traverse__
(
request
,
entry_name
)
bobo_got
=
1
if
type
(
subobject
)
is
type
(())
and
len
(
subobject
)
>
1
:
# Add additional parents into the path
parents
[
-
1
:]
=
list
(
subobject
[:
-
1
])
object
,
subobject
=
subobject
[
-
2
:]
except
(
AttributeError
,
KeyError
):
pass
if
not
bobo_got
:
if
debug_mode
:
return
response
.
debugError
(
"Cannot locate object at: %s"
%
URL
)
else
:
return
response
.
notFoundError
(
URL
)
else
:
try
:
# Note - no_acquire_flag is necessary to support
# things like DAV. We have to make sure
...
...
lib/python/ZPublisher/tests/testBaseRequest.py
View file @
836f07cf
...
...
@@ -50,17 +50,6 @@ class DummyObjectWithBBT(DummyObjectBasic):
def
__bobo_traverse__
(
self
,
REQUEST
,
name
):
raise
AttributeError
,
name
def
dummyMethod
(
self
):
"""Dummy method with docstring."""
return
'Dummy Value'
def
__getitem__
(
self
,
name
):
if
name
.
startswith
(
'no_key_'
):
raise
KeyError
,
name
name
=
name
.
replace
(
'key_'
,
''
)
return
getattr
(
self
,
name
)
class
DummyObjectWithBD
(
DummyObjectBasic
):
"""Dummy class with docstring."""
...
...
@@ -75,7 +64,7 @@ class DummyObjectWithBDBBT(DummyObjectWithBD):
"""Dummy class with docstring."""
def
__bobo_traverse__
(
self
,
REQUEST
,
name
):
if
name
==
self
.
default_path
[
0
]:
if
name
==
self
.
_
default_path
[
0
]:
return
getattr
(
self
,
name
)
raise
AttributeError
,
name
...
...
@@ -165,28 +154,6 @@ class TestBaseRequest(TestCase):
r
=
self
.
makeBaseRequest
()
self
.
failUnlessRaises
(
NotFound
,
r
.
traverse
,
'folder/objWithBBT/bbt_foo'
)
def
test_traverse_withBBT_fallback_getattr
(
self
):
# Test that if __bobo_traverse__ raises AttributeError
# that we fallback to getattr()
r
=
self
.
makeBaseRequest
()
r
.
traverse
(
'folder/objWithBBT/dummyMethod'
)
self
.
assertEqual
(
r
.
URL
,
'/folder/objWithBBT/dummyMethod'
)
def
test_traverse_withBBT_fallback_getitem
(
self
):
# Test that if __bobo_traverse__ raises AttributeError
# and getattr raises AttributeError
# that we fallback to __getitem__
r
=
self
.
makeBaseRequest
()
r
.
traverse
(
'folder/objWithBBT/key_dummyMethod'
)
self
.
assertEqual
(
r
.
URL
,
'/folder/objWithBBT/key_dummyMethod'
)
def
test_traverse_withBBT_fallback_getitem_NotFound
(
self
):
# Test that if all else fails, we get a NotFound
from
ZPublisher
import
NotFound
r
=
self
.
makeBaseRequest
()
self
.
failUnlessRaises
(
NotFound
,
r
.
traverse
,
'folder/objWithBBT/no_key_dummyMethod'
)
def
test_traverse_withBDBBT
(
self
):
# Test for an object which has a __browser_default__
# and __bobo_traverse__
...
...
@@ -202,7 +169,6 @@ class TestBaseRequest(TestCase):
# Test for an object which has a __browser_default__
# and __bobo_traverse__
# __bobo_traverse__ should raise an AttributeError, which will
# end up falling back to getattr, then __getitem__ to finally
# raise a NotFound
from
ZPublisher
import
NotFound
r
=
self
.
makeBaseRequest
()
...
...
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