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
e1a6d7d6
Commit
e1a6d7d6
authored
May 20, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge janitorial changes from 2.12 branch.
parent
97e90703
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
73 deletions
+64
-73
src/Products/SiteAccess/SiteRoot.py
src/Products/SiteAccess/SiteRoot.py
+0
-2
src/Products/SiteAccess/VirtualHostMonster.py
src/Products/SiteAccess/VirtualHostMonster.py
+0
-6
src/Products/SiteAccess/__init__.py
src/Products/SiteAccess/__init__.py
+9
-4
src/Products/SiteAccess/tests/testSiteRoot.py
src/Products/SiteAccess/tests/testSiteRoot.py
+20
-26
src/Products/SiteAccess/tests/testVirtualHostMonster.py
src/Products/SiteAccess/tests/testVirtualHostMonster.py
+35
-35
No files found.
src/Products/SiteAccess/SiteRoot.py
View file @
e1a6d7d6
...
...
@@ -6,10 +6,8 @@ from cgi import escape
import
os
from
Acquisition
import
Implicit
from
Acquisition
import
ImplicitAcquisitionWrapper
from
App.Dialogs
import
MessageDialog
from
App.special_dtml
import
DTMLFile
from
ExtensionClass
import
Base
from
OFS.SimpleItem
import
Item
from
Persistence
import
Persistent
from
ZPublisher.BeforeTraverse
import
NameCaller
...
...
src/Products/SiteAccess/VirtualHostMonster.py
View file @
e1a6d7d6
...
...
@@ -2,12 +2,8 @@
Defines the VirtualHostMonster class
"""
import
os
from
AccessControl.Permissions
import
view
as
View
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
Acquisition
import
aq_inner
from
Acquisition
import
aq_parent
from
Acquisition
import
Implicit
from
App.class_init
import
InitializeClass
from
App.Dialogs
import
MessageDialog
...
...
@@ -21,8 +17,6 @@ from ZPublisher.BeforeTraverse import unregisterBeforeTraverse
from
ZPublisher.BaseRequest
import
quote
from
zExceptions
import
BadRequest
from
AccessRule
import
_swallow
class
VirtualHostMonster
(
Persistent
,
Item
,
Implicit
):
"""Provide a simple drop-in solution for virtual hosting.
"""
...
...
src/Products/SiteAccess/__init__.py
View file @
e1a6d7d6
__doc__
=
"""SiteAccess product"""
import
SiteRoot
,
AccessRule
,
VirtualHostMonster
"""SiteAccess product
"""
def
initialize
(
context
):
import
SiteRoot
import
AccessRule
import
VirtualHostMonster
context
.
registerClass
(
instance_class
=
SiteRoot
.
SiteRoot
,
permission
=
'Add Site Roots'
,
constructors
=
SiteRoot
.
constructors
,
legacy
=
SiteRoot
.
constructors
,
icon
=
'www/SiteRoot.gif'
)
context
.
registerClass
(
instance_class
=
AccessRule
.
AccessRule
,
permission
=
'Manage Access Rules'
,
constructors
=
AccessRule
.
constructors
,
icon
=
'www/AccessRule.gif'
)
context
.
registerClass
(
instance_class
=
VirtualHostMonster
.
VirtualHostMonster
,
permission
=
'Add Virtual Host Monsters'
,
constructors
=
VirtualHostMonster
.
constructors
,
icon
=
'www/VirtualHostMonster.gif'
)
context
.
registerHelp
()
src/Products/SiteAccess/tests/testSiteRoot.py
View file @
e1a6d7d6
...
...
@@ -4,47 +4,41 @@ These tests verify that the request URL headers, in particular ACTUAL_URL, are
set correctly when a SiteRoot is used.
See http://www.zope.org/Collectors/Zope/2077
"""
from
Testing.makerequest
import
makerequest
import
Zope2
Zope2
.
startup
()
import
transaction
import
unittest
class
SiteRootRegressions
(
unittest
.
TestCase
):
def
setUp
(
self
):
import
transaction
from
Testing.makerequest
import
makerequest
from
Testing.ZopeTestCase.ZopeLite
import
app
transaction
.
begin
()
self
.
app
=
makerequest
(
Zope2
.
app
())
try
:
self
.
app
.
manage_addFolder
(
'folder'
)
self
.
app
.
folder
.
manage_addProduct
[
'SiteAccess'
].
manage_addSiteRoot
(
title
=
'SiteRoot'
,
base
=
'http://test_base'
,
path
=
'/test_path'
)
self
.
app
.
REQUEST
.
set
(
'PARENTS'
,
[
self
.
app
])
self
.
app
.
REQUEST
.
traverse
(
'/folder'
)
except
:
self
.
tearDown
()
self
.
app
=
makerequest
(
app
())
self
.
app
.
manage_addFolder
(
'folder'
)
p_disp
=
self
.
app
.
folder
.
manage_addProduct
[
'SiteAccess'
]
p_disp
.
manage_addSiteRoot
(
title
=
'SiteRoot'
,
base
=
'http://test_base'
,
path
=
'/test_path'
)
self
.
app
.
REQUEST
.
set
(
'PARENTS'
,
[
self
.
app
])
self
.
app
.
REQUEST
.
traverse
(
'/folder'
)
def
tearDown
(
self
):
import
transaction
transaction
.
abort
()
self
.
app
.
_p_jar
.
close
()
def
testRequest
(
self
):
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'SERVER_URL'
],
'http://test_base'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'URL'
],
'http://test_base/test_path/index_html'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://test_base/test_path'
)
def
testAbsoluteUrl
(
self
):
self
.
assertEqual
(
self
.
app
.
folder
.
absolute_url
(),
'http://test_base/test_path'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'URL'
],
'http://test_base/test_path/index_html'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://test_base/test_path'
)
def
testAbsoluteUrl
(
self
):
self
.
assertEqual
(
self
.
app
.
folder
.
absolute_url
(),
'http://test_base/test_path'
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
SiteRootRegressions
))
return
suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
src/Products/SiteAccess/tests/testVirtualHostMonster.py
View file @
e1a6d7d6
...
...
@@ -6,38 +6,30 @@ works correctly in a VHM environment.
Also see http://zope.org/Collectors/Zope/809
Note: Tests require Zope >= 2.7
$Id$
"""
from
Testing.makerequest
import
makerequest
import
Zope2
Zope2
.
startup
()
import
transaction
import
unittest
class
VHMRegressions
(
unittest
.
TestCase
):
def
setUp
(
self
):
import
transaction
from
Testing.makerequest
import
makerequest
from
Testing.ZopeTestCase.ZopeLite
import
app
transaction
.
begin
()
self
.
app
=
makerequest
(
Zope2
.
app
())
try
:
if
not
hasattr
(
self
.
app
,
'virtual_hosting'
):
# If ZopeLite was imported, we have no default virtual host monster
from
Products.SiteAccess.VirtualHostMonster
import
manage_addVirtualHostMonster
manage_addVirtualHostMonster
(
self
.
app
,
'virtual_hosting'
)
self
.
app
.
manage_addFolder
(
'folder'
)
self
.
app
.
folder
.
manage_addDTMLMethod
(
'doc'
,
''
)
self
.
app
.
REQUEST
.
set
(
'PARENTS'
,
[
self
.
app
])
self
.
traverse
=
self
.
app
.
REQUEST
.
traverse
except
:
self
.
tearDown
()
self
.
app
=
makerequest
(
app
())
if
'virtual_hosting'
not
in
self
.
app
.
objectIds
():
# If ZopeLite was imported, we have no default virtual
# host monster
from
Products.SiteAccess.VirtualHostMonster
\
import
manage_addVirtualHostMonster
manage_addVirtualHostMonster
(
self
.
app
,
'virtual_hosting'
)
self
.
app
.
manage_addFolder
(
'folder'
)
self
.
app
.
folder
.
manage_addDTMLMethod
(
'doc'
,
''
)
self
.
app
.
REQUEST
.
set
(
'PARENTS'
,
[
self
.
app
])
self
.
traverse
=
self
.
app
.
REQUEST
.
traverse
def
tearDown
(
self
):
import
transaction
transaction
.
abort
()
self
.
app
.
_p_jar
.
close
()
...
...
@@ -61,14 +53,26 @@ class VHMRegressions(unittest.TestCase):
def
test_actual_url
(
self
):
self
.
app
.
folder
.
manage_addDTMLMethod
(
'index_html'
,
''
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/doc/'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/doc/'
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/doc'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/doc'
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/'
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/'
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80'
'/folder/VirtualHostRoot/doc/'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/doc/'
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80'
'/folder/VirtualHostRoot/doc'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/doc'
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80'
'/folder/VirtualHostRoot/'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/'
)
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80'
'/folder/VirtualHostRoot'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/'
)
def
gen_cases
():
for
vbase
,
ubase
in
(
...
...
@@ -174,7 +178,3 @@ def test_suite():
suite
.
addTest
(
unittest
.
makeSuite
(
VHMRegressions
))
suite
.
addTest
(
unittest
.
makeSuite
(
VHMAddingTests
))
return
suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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