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
be2ea721
Commit
be2ea721
authored
Sep 01, 2007
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
We do need to do some wrapping when objects are found via namespace
traversal.
parent
51f1cb82
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
0 deletions
+68
-0
lib/python/OFS/Traversable.py
lib/python/OFS/Traversable.py
+3
-0
lib/python/Products/Five/browser/tests/aqlegacy.py
lib/python/Products/Five/browser/tests/aqlegacy.py
+19
-0
lib/python/Products/Five/browser/tests/aqlegacy.zcml
lib/python/Products/Five/browser/tests/aqlegacy.zcml
+20
-0
lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
+22
-0
lib/python/ZPublisher/BaseRequest.py
lib/python/ZPublisher/BaseRequest.py
+4
-0
No files found.
lib/python/OFS/Traversable.py
View file @
be2ea721
...
@@ -23,6 +23,7 @@ from AccessControl import getSecurityManager
...
@@ -23,6 +23,7 @@ from AccessControl import getSecurityManager
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
from
AccessControl.ZopeGuards
import
guarded_getattr
from
AccessControl.ZopeGuards
import
guarded_getattr
from
Acquisition
import
Acquired
,
aq_inner
,
aq_parent
,
aq_acquire
,
aq_base
from
Acquisition
import
Acquired
,
aq_inner
,
aq_parent
,
aq_acquire
,
aq_base
from
Acquisition.interfaces
import
IAcquirer
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
OFS.interfaces
import
ITraversable
from
OFS.interfaces
import
ITraversable
...
@@ -193,6 +194,8 @@ class Traversable:
...
@@ -193,6 +194,8 @@ class Traversable:
try
:
try
:
next
=
namespaceLookup
(
next
=
namespaceLookup
(
ns
,
nm
,
obj
,
aq_acquire
(
self
,
'REQUEST'
))
ns
,
nm
,
obj
,
aq_acquire
(
self
,
'REQUEST'
))
if
IAcquirer
.
providedBy
(
next
):
next
=
next
.
__of__
(
obj
)
if
restricted
and
not
validate
(
if
restricted
and
not
validate
(
obj
,
obj
,
name
,
next
):
obj
,
obj
,
name
,
next
):
raise
Unauthorized
(
name
)
raise
Unauthorized
(
name
)
...
...
lib/python/Products/Five/browser/tests/aqlegacy.py
View file @
be2ea721
...
@@ -18,7 +18,10 @@ which mix-in one of the Acquisition base classes without knowing
...
@@ -18,7 +18,10 @@ which mix-in one of the Acquisition base classes without knowing
better) still work.
better) still work.
"""
"""
import
Acquisition
import
Acquisition
import
OFS.SimpleItem
from
zope.interface
import
implements
from
zope.interface
import
implements
from
zope.traversing.interfaces
import
ITraversable
from
zope.contentprovider.interfaces
import
IContentProvider
from
zope.contentprovider.interfaces
import
IContentProvider
from
Products.Five
import
BrowserView
from
Products.Five
import
BrowserView
from
Products.Five.browser.pagetemplatefile
import
ViewPageTemplateFile
from
Products.Five.browser.pagetemplatefile
import
ViewPageTemplateFile
...
@@ -115,3 +118,19 @@ class BrowserViewViewlet(BrowserView):
...
@@ -115,3 +118,19 @@ class BrowserViewViewlet(BrowserView):
def
render
(
self
):
def
render
(
self
):
return
'BrowserView viewlet'
return
'BrowserView viewlet'
class
LegacyNamespace
(
object
):
implements
(
ITraversable
)
def
__init__
(
self
,
context
,
request
):
self
.
context
=
context
self
.
request
=
request
def
traverse
(
self
,
name
,
ignored
):
return
LegacyNamespaceObject
(
name
)
class
LegacyNamespaceObject
(
OFS
.
SimpleItem
.
SimpleItem
):
def
__init__
(
self
,
name
):
self
.
id
=
name
lib/python/Products/Five/browser/tests/aqlegacy.zcml
View file @
be2ea721
...
@@ -112,4 +112,24 @@
...
@@ -112,4 +112,24 @@
permission="zope.Public"
permission="zope.Public"
/>
/>
<!-- Namespace traversal -->
<adapter
for="*"
factory=".aqlegacy.LegacyNamespace"
name="aqlegacy"
/>
<adapter
for="* *"
factory=".aqlegacy.LegacyNamespace"
name="aqlegacy"
/>
<browser:page
for=".aqlegacy.LegacyNamespaceObject"
name="index.html"
template="falcon.pt"
permission="zope.Public"
/>
</configure>
</configure>
\ No newline at end of file
lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
View file @
be2ea721
...
@@ -141,6 +141,28 @@ Testing legacy content providers and viewlets
...
@@ -141,6 +141,28 @@ Testing legacy content providers and viewlets
Viewlet inheriting from Explicit</p>
Viewlet inheriting from Explicit</p>
Testing namespace traversal
===========================
Namespace traversal can turn up objects during traversal without
attribute access. That means they might not be wrapped by default.
Here we make sure that they are wrapped and that things like the
request can be acquired.
First let's try ``restrictedTraverse()``:
>>> foo = self.folder.restrictedTraverse('++aqlegacy++foo')
>>> import Acquisition
>>> Acquisition.aq_acquire(foo, 'REQUEST')
<HTTPRequest, URL=http://nohost>
Now let's try URL traversal:
>>> browser.open('http://localhost/test_folder_1_/++aqlegacy++foo/index.html')
>>> print browser.contents
<p>The falcon has taken flight</p>
Clean up
Clean up
--------
--------
...
...
lib/python/ZPublisher/BaseRequest.py
View file @
be2ea721
...
@@ -18,6 +18,7 @@ from urllib import quote as urllib_quote
...
@@ -18,6 +18,7 @@ from urllib import quote as urllib_quote
import
xmlrpc
import
xmlrpc
from
zExceptions
import
Forbidden
,
Unauthorized
,
NotFound
from
zExceptions
import
Forbidden
,
Unauthorized
,
NotFound
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
Acquisition.interfaces
import
IAcquirer
from
zope.interface
import
implements
,
providedBy
,
Interface
from
zope.interface
import
implements
,
providedBy
,
Interface
from
zope.component
import
queryMultiAdapter
from
zope.component
import
queryMultiAdapter
...
@@ -312,6 +313,9 @@ class BaseRequest:
...
@@ -312,6 +313,9 @@ class BaseRequest:
ob2
=
namespaceLookup
(
ns
,
nm
,
ob
,
self
)
ob2
=
namespaceLookup
(
ns
,
nm
,
ob
,
self
)
except
TraversalError
:
except
TraversalError
:
raise
KeyError
(
ob
,
name
)
raise
KeyError
(
ob
,
name
)
if
IAcquirer
.
providedBy
(
ob2
):
ob2
=
ob2
.
__of__
(
ob
)
return
ob2
return
ob2
if
name
==
'.'
:
if
name
==
'.'
:
...
...
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