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
0d876e35
Commit
0d876e35
authored
May 21, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge saner SiteRoot impl. from 2.12 branch.
parent
7c57d06e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
45 deletions
+17
-45
src/Products/SiteAccess/SiteRoot.py
src/Products/SiteAccess/SiteRoot.py
+17
-35
src/Products/SiteAccess/tests/testSiteRoot.py
src/Products/SiteAccess/tests/testSiteRoot.py
+0
-10
No files found.
src/Products/SiteAccess/SiteRoot.py
View file @
0d876e35
...
...
@@ -87,20 +87,6 @@ class SiteRoot(Traverser, Implicit):
self
.
title
=
title
.
strip
()
self
.
base
=
base
=
base
.
strip
()
self
.
path
=
path
=
path
.
strip
()
if
base
:
self
.
SiteRootBASE
=
base
else
:
try
:
del
self
.
SiteRootBASE
except
:
pass
if
path
:
self
.
SiteRootPATH
=
path
else
:
try
:
del
self
.
SiteRootPATH
except
:
pass
def
manage_edit
(
self
,
title
,
base
,
path
,
REQUEST
=
None
):
""" Set the title, base, and path.
...
...
@@ -114,30 +100,26 @@ class SiteRoot(Traverser, Implicit):
def
__call__
(
self
,
client
,
request
,
response
=
None
):
""" Traversing.
"""
rq
=
request
if
SUPPRESS_SITEROOT
:
return
if
'_SUPPRESS_SITEROOT'
in
_swallow
(
r
equest
,
'_SUPPRESS'
):
r
equest
.
setVirtualRoot
(
request
.
steps
)
if
'_SUPPRESS_SITEROOT'
in
_swallow
(
r
q
,
'_SUPPRESS'
):
r
q
.
setVirtualRoot
(
rq
.
steps
)
return
srd
=
[
None
,
None
]
for
i
in
(
0
,
1
):
srp
=
(
'SiteRootBASE'
,
'SiteRootPATH'
)[
i
]
try
:
srd
[
i
]
=
getattr
(
self
,
srp
)
except
AttributeError
:
srd
[
i
]
=
request
.
get
(
srp
,
None
)
if
srd
[
i
]
is
None
:
srd
[
i
]
=
request
.
environ
.
get
(
srp
,
None
)
if
srd
[
0
]
is
not
None
:
request
[
'ACTUAL_URL'
]
=
request
[
'ACTUAL_URL'
].
replace
(
request
[
'SERVER_URL'
],
srd
[
0
])
request
[
'SERVER_URL'
]
=
srd
[
0
]
request
.
_resetURLS
()
if
srd
[
1
]
is
not
None
:
old
=
request
[
'URL'
]
request
.
setVirtualRoot
(
srd
[
1
])
request
[
'ACTUAL_URL'
]
=
request
[
'ACTUAL_URL'
].
replace
(
old
,
request
[
'URL'
])
base
=
(
self
.
base
or
rq
.
get
(
'SiteRootBASE'
)
or
rq
.
environ
.
get
(
'SiteRootBASE'
))
path
=
(
self
.
path
or
rq
.
get
(
'SiteRootPATH'
)
or
rq
.
environ
.
get
(
'SiteRootPATH'
))
if
base
is
not
None
:
rq
[
'ACTUAL_URL'
]
=
rq
[
'ACTUAL_URL'
].
replace
(
rq
[
'SERVER_URL'
],
base
)
rq
[
'SERVER_URL'
]
=
base
rq
.
_resetURLS
()
if
path
is
not
None
:
old
=
rq
[
'URL'
]
rq
.
setVirtualRoot
(
path
)
rq
[
'ACTUAL_URL'
]
=
rq
[
'ACTUAL_URL'
].
replace
(
old
,
rq
[
'URL'
])
def
get_size
(
self
):
""" Make FTP happy
...
...
src/Products/SiteAccess/tests/testSiteRoot.py
View file @
0d876e35
...
...
@@ -127,18 +127,12 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
siteroot
.
title
,
'TITLE'
)
self
.
assertEqual
(
siteroot
.
base
,
''
)
self
.
assertEqual
(
siteroot
.
path
,
''
)
# XXX Why aren't these defaulted to None at class scope?
# Even better: why do they exist at all?
self
.
failUnless
(
getattr
(
siteroot
,
'SiteRootBase'
,
self
)
is
self
)
self
.
failUnless
(
getattr
(
siteroot
,
'SiteRootPath'
,
self
)
is
self
)
def
test___init___w_base_and_path
(
self
):
siteroot
=
self
.
_makeOne
(
base
=
'http://example.com'
,
path
=
'/path'
)
self
.
assertEqual
(
siteroot
.
title
,
'TITLE'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/path'
)
self
.
assertEqual
(
siteroot
.
SiteRootBASE
,
'http://example.com'
)
self
.
assertEqual
(
siteroot
.
SiteRootPATH
,
'/path'
)
def
test_manage_edit_no_REQUEST
(
self
):
siteroot
=
self
.
_makeOne
(
title
=
'Before'
,
...
...
@@ -150,8 +144,6 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
self
.
assertEqual
(
siteroot
.
SiteRootBASE
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
SiteRootPATH
,
'/after'
)
def
test_manage_edit_w_REQUEST
(
self
):
siteroot
=
self
.
_makeOne
(
title
=
'Before'
,
...
...
@@ -165,8 +157,6 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
self
.
assertEqual
(
siteroot
.
SiteRootBASE
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
SiteRootPATH
,
'/after'
)
def
test___call___w_SUPPRESS_SITEROOT_set
(
self
):
self
.
_set_SUPPRESS_SITEROOT
(
1
)
...
...
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