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
3caa940b
Commit
3caa940b
authored
May 21, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove some insanity, now that we have coverage.
parent
4a6b35ad
Changes
2
Hide 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 @
3caa940b
...
@@ -87,20 +87,6 @@ class SiteRoot(Traverser, Implicit):
...
@@ -87,20 +87,6 @@ class SiteRoot(Traverser, Implicit):
self
.
title
=
title
.
strip
()
self
.
title
=
title
.
strip
()
self
.
base
=
base
=
base
.
strip
()
self
.
base
=
base
=
base
.
strip
()
self
.
path
=
path
=
path
.
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
):
def
manage_edit
(
self
,
title
,
base
,
path
,
REQUEST
=
None
):
""" Set the title, base, and path.
""" Set the title, base, and path.
...
@@ -114,30 +100,26 @@ class SiteRoot(Traverser, Implicit):
...
@@ -114,30 +100,26 @@ class SiteRoot(Traverser, Implicit):
def
__call__
(
self
,
client
,
request
,
response
=
None
):
def
__call__
(
self
,
client
,
request
,
response
=
None
):
""" Traversing.
""" Traversing.
"""
"""
rq
=
request
if
SUPPRESS_SITEROOT
:
if
SUPPRESS_SITEROOT
:
return
return
if
'_SUPPRESS_SITEROOT'
in
_swallow
(
r
equest
,
'_SUPPRESS'
):
if
'_SUPPRESS_SITEROOT'
in
_swallow
(
r
q
,
'_SUPPRESS'
):
r
equest
.
setVirtualRoot
(
request
.
steps
)
r
q
.
setVirtualRoot
(
rq
.
steps
)
return
return
srd
=
[
None
,
None
]
base
=
(
self
.
base
or
for
i
in
(
0
,
1
):
rq
.
get
(
'SiteRootBASE'
)
or
srp
=
(
'SiteRootBASE'
,
'SiteRootPATH'
)[
i
]
rq
.
environ
.
get
(
'SiteRootBASE'
))
try
:
path
=
(
self
.
path
or
srd
[
i
]
=
getattr
(
self
,
srp
)
rq
.
get
(
'SiteRootPATH'
)
or
except
AttributeError
:
rq
.
environ
.
get
(
'SiteRootPATH'
))
srd
[
i
]
=
request
.
get
(
srp
,
None
)
if
base
is
not
None
:
if
srd
[
i
]
is
None
:
rq
[
'ACTUAL_URL'
]
=
rq
[
'ACTUAL_URL'
].
replace
(
rq
[
'SERVER_URL'
],
base
)
srd
[
i
]
=
request
.
environ
.
get
(
srp
,
None
)
rq
[
'SERVER_URL'
]
=
base
if
srd
[
0
]
is
not
None
:
rq
.
_resetURLS
()
request
[
'ACTUAL_URL'
]
=
request
[
'ACTUAL_URL'
].
replace
(
if
path
is
not
None
:
request
[
'SERVER_URL'
],
srd
[
0
])
old
=
rq
[
'URL'
]
request
[
'SERVER_URL'
]
=
srd
[
0
]
rq
.
setVirtualRoot
(
path
)
request
.
_resetURLS
()
rq
[
'ACTUAL_URL'
]
=
rq
[
'ACTUAL_URL'
].
replace
(
old
,
rq
[
'URL'
])
if
srd
[
1
]
is
not
None
:
old
=
request
[
'URL'
]
request
.
setVirtualRoot
(
srd
[
1
])
request
[
'ACTUAL_URL'
]
=
request
[
'ACTUAL_URL'
].
replace
(
old
,
request
[
'URL'
])
def
get_size
(
self
):
def
get_size
(
self
):
""" Make FTP happy
""" Make FTP happy
...
...
src/Products/SiteAccess/tests/testSiteRoot.py
View file @
3caa940b
...
@@ -127,18 +127,12 @@ class SiteRootTests(unittest.TestCase):
...
@@ -127,18 +127,12 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
siteroot
.
title
,
'TITLE'
)
self
.
assertEqual
(
siteroot
.
title
,
'TITLE'
)
self
.
assertEqual
(
siteroot
.
base
,
''
)
self
.
assertEqual
(
siteroot
.
base
,
''
)
self
.
assertEqual
(
siteroot
.
path
,
''
)
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
):
def
test___init___w_base_and_path
(
self
):
siteroot
=
self
.
_makeOne
(
base
=
'http://example.com'
,
path
=
'/path'
)
siteroot
=
self
.
_makeOne
(
base
=
'http://example.com'
,
path
=
'/path'
)
self
.
assertEqual
(
siteroot
.
title
,
'TITLE'
)
self
.
assertEqual
(
siteroot
.
title
,
'TITLE'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://example.com'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/path'
)
self
.
assertEqual
(
siteroot
.
path
,
'/path'
)
self
.
assertEqual
(
siteroot
.
SiteRootBASE
,
'http://example.com'
)
self
.
assertEqual
(
siteroot
.
SiteRootPATH
,
'/path'
)
def
test_manage_edit_no_REQUEST
(
self
):
def
test_manage_edit_no_REQUEST
(
self
):
siteroot
=
self
.
_makeOne
(
title
=
'Before'
,
siteroot
=
self
.
_makeOne
(
title
=
'Before'
,
...
@@ -150,8 +144,6 @@ class SiteRootTests(unittest.TestCase):
...
@@ -150,8 +144,6 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
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
):
def
test_manage_edit_w_REQUEST
(
self
):
siteroot
=
self
.
_makeOne
(
title
=
'Before'
,
siteroot
=
self
.
_makeOne
(
title
=
'Before'
,
...
@@ -165,8 +157,6 @@ class SiteRootTests(unittest.TestCase):
...
@@ -165,8 +157,6 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
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
):
def
test___call___w_SUPPRESS_SITEROOT_set
(
self
):
self
.
_set_SUPPRESS_SITEROOT
(
1
)
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