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
72994a7d
Commit
72994a7d
authored
Aug 19, 2010
by
Jens Vagelpohl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- LP #193122: New method getVirtualRoot added to the Request class
parent
ff2e6d82
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+7
-0
src/ZPublisher/tests/testHTTPRequest.py
src/ZPublisher/tests/testHTTPRequest.py
+10
-0
No files found.
doc/CHANGES.rst
View file @
72994a7d
...
@@ -15,6 +15,8 @@ Bugs Fixed
...
@@ -15,6 +15,8 @@ Bugs Fixed
Features Added
Features Added
++++++++++++++
++++++++++++++
- LP #193122: New method getVirtualRoot added to the Request class
- Updated test assertions to use unittest's ``assert*`` methods in favor of
- Updated test assertions to use unittest's ``assert*`` methods in favor of
their deprecated `fail*` aliases.
their deprecated `fail*` aliases.
...
...
src/ZPublisher/HTTPRequest.py
View file @
72994a7d
...
@@ -230,6 +230,13 @@ class HTTPRequest(BaseRequest):
...
@@ -230,6 +230,13 @@ class HTTPRequest(BaseRequest):
other
[
'VirtualRootPhysicalPath'
]
=
parents
[
-
1
].
getPhysicalPath
()
other
[
'VirtualRootPhysicalPath'
]
=
parents
[
-
1
].
getPhysicalPath
()
self
.
_resetURLS
()
self
.
_resetURLS
()
def
getVirtualRoot
(
self
):
""" Return a slash-separated virtual root.
If it is same as the physical root, return ''.
"""
return
'/'
.
join
([
''
]
+
self
.
_script
)
def
physicalPathToVirtualPath
(
self
,
path
):
def
physicalPathToVirtualPath
(
self
,
path
):
""" Remove the path to the VirtualRoot from a physical path """
""" Remove the path to the VirtualRoot from a physical path """
if
type
(
path
)
is
type
(
''
):
if
type
(
path
)
is
type
(
''
):
...
...
src/ZPublisher/tests/testHTTPRequest.py
View file @
72994a7d
...
@@ -1036,6 +1036,16 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -1036,6 +1036,16 @@ class HTTPRequestTests(unittest.TestCase):
'{"intkey":123,"stringkey":"blah"}'
)
'{"intkey":123,"stringkey":"blah"}'
)
self
.
assertEquals
(
req
.
cookies
[
'anothercookie'
],
'boring'
)
self
.
assertEquals
(
req
.
cookies
[
'anothercookie'
],
'boring'
)
def
test_getVirtualRoot
(
self
):
# https://bugs.launchpad.net/zope2/+bug/193122
req
=
self
.
_makeOne
()
req
.
_script
=
[]
self
.
assertEquals
(
req
.
getVirtualRoot
(),
''
)
req
.
_script
=
[
'foo'
,
'bar'
]
self
.
assertEquals
(
req
.
getVirtualRoot
(),
'/foo/bar'
)
TEST_ENVIRON
=
{
TEST_ENVIRON
=
{
'CONTENT_TYPE'
:
'multipart/form-data; boundary=12345'
,
'CONTENT_TYPE'
:
'multipart/form-data; boundary=12345'
,
'REQUEST_METHOD'
:
'POST'
,
'REQUEST_METHOD'
:
'POST'
,
...
...
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