Commit e1a6d7d6 authored by Tres Seaver's avatar Tres Seaver

Merge janitorial changes from 2.12 branch.

parent 97e90703
...@@ -6,10 +6,8 @@ from cgi import escape ...@@ -6,10 +6,8 @@ from cgi import escape
import os import os
from Acquisition import Implicit from Acquisition import Implicit
from Acquisition import ImplicitAcquisitionWrapper
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
from App.special_dtml import DTMLFile from App.special_dtml import DTMLFile
from ExtensionClass import Base
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Persistence import Persistent from Persistence import Persistent
from ZPublisher.BeforeTraverse import NameCaller from ZPublisher.BeforeTraverse import NameCaller
......
...@@ -2,12 +2,8 @@ ...@@ -2,12 +2,8 @@
Defines the VirtualHostMonster class Defines the VirtualHostMonster class
""" """
import os
from AccessControl.Permissions import view as View from AccessControl.Permissions import view as View
from AccessControl.SecurityInfo import ClassSecurityInfo from AccessControl.SecurityInfo import ClassSecurityInfo
from Acquisition import aq_inner
from Acquisition import aq_parent
from Acquisition import Implicit from Acquisition import Implicit
from App.class_init import InitializeClass from App.class_init import InitializeClass
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
...@@ -21,8 +17,6 @@ from ZPublisher.BeforeTraverse import unregisterBeforeTraverse ...@@ -21,8 +17,6 @@ from ZPublisher.BeforeTraverse import unregisterBeforeTraverse
from ZPublisher.BaseRequest import quote from ZPublisher.BaseRequest import quote
from zExceptions import BadRequest from zExceptions import BadRequest
from AccessRule import _swallow
class VirtualHostMonster(Persistent, Item, Implicit): class VirtualHostMonster(Persistent, Item, Implicit):
"""Provide a simple drop-in solution for virtual hosting. """Provide a simple drop-in solution for virtual hosting.
""" """
......
__doc__="""SiteAccess product""" """SiteAccess product
"""
import SiteRoot, AccessRule, VirtualHostMonster
def initialize(context): def initialize(context):
import SiteRoot
import AccessRule
import VirtualHostMonster
context.registerClass(instance_class=SiteRoot.SiteRoot, context.registerClass(instance_class=SiteRoot.SiteRoot,
permission='Add Site Roots', permission='Add Site Roots',
constructors=SiteRoot.constructors, legacy=SiteRoot.constructors, constructors=SiteRoot.constructors, legacy=SiteRoot.constructors,
icon='www/SiteRoot.gif') icon='www/SiteRoot.gif')
context.registerClass(instance_class=AccessRule.AccessRule, context.registerClass(instance_class=AccessRule.AccessRule,
permission='Manage Access Rules', constructors=AccessRule.constructors, permission='Manage Access Rules', constructors=AccessRule.constructors,
icon='www/AccessRule.gif') icon='www/AccessRule.gif')
context.registerClass(instance_class=VirtualHostMonster.VirtualHostMonster, context.registerClass(instance_class=VirtualHostMonster.VirtualHostMonster,
permission='Add Virtual Host Monsters', permission='Add Virtual Host Monsters',
constructors=VirtualHostMonster.constructors, constructors=VirtualHostMonster.constructors,
icon='www/VirtualHostMonster.gif') icon='www/VirtualHostMonster.gif')
context.registerHelp() context.registerHelp()
...@@ -4,47 +4,41 @@ These tests verify that the request URL headers, in particular ACTUAL_URL, are ...@@ -4,47 +4,41 @@ These tests verify that the request URL headers, in particular ACTUAL_URL, are
set correctly when a SiteRoot is used. set correctly when a SiteRoot is used.
See http://www.zope.org/Collectors/Zope/2077 See http://www.zope.org/Collectors/Zope/2077
""" """
from Testing.makerequest import makerequest
import Zope2
Zope2.startup()
import transaction
import unittest import unittest
class SiteRootRegressions(unittest.TestCase): class SiteRootRegressions(unittest.TestCase):
def setUp(self): def setUp(self):
import transaction
from Testing.makerequest import makerequest
from Testing.ZopeTestCase.ZopeLite import app
transaction.begin() transaction.begin()
self.app = makerequest(Zope2.app()) self.app = makerequest(app())
try: self.app.manage_addFolder('folder')
self.app.manage_addFolder('folder') p_disp = self.app.folder.manage_addProduct['SiteAccess']
self.app.folder.manage_addProduct['SiteAccess'].manage_addSiteRoot(title = 'SiteRoot', base = 'http://test_base', path = '/test_path') p_disp.manage_addSiteRoot(title='SiteRoot',
self.app.REQUEST.set('PARENTS', [self.app]) base='http://test_base',
self.app.REQUEST.traverse('/folder') path='/test_path')
self.app.REQUEST.set('PARENTS', [self.app])
except: self.app.REQUEST.traverse('/folder')
self.tearDown()
def tearDown(self): def tearDown(self):
import transaction
transaction.abort() transaction.abort()
self.app._p_jar.close() self.app._p_jar.close()
def testRequest(self): def testRequest(self):
self.assertEqual(self.app.REQUEST['SERVER_URL'], 'http://test_base') 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['URL'],
self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://test_base/test_path') 'http://test_base/test_path/index_html')
def testAbsoluteUrl(self): self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
self.assertEqual(self.app.folder.absolute_url(), 'http://test_base/test_path') 'http://test_base/test_path')
def testAbsoluteUrl(self):
self.assertEqual(self.app.folder.absolute_url(),
'http://test_base/test_path')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SiteRootRegressions)) suite.addTest(unittest.makeSuite(SiteRootRegressions))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -6,38 +6,30 @@ works correctly in a VHM environment. ...@@ -6,38 +6,30 @@ works correctly in a VHM environment.
Also see http://zope.org/Collectors/Zope/809 Also see http://zope.org/Collectors/Zope/809
Note: Tests require Zope >= 2.7 Note: Tests require Zope >= 2.7
$Id$
""" """
from Testing.makerequest import makerequest
import Zope2
Zope2.startup()
import transaction
import unittest import unittest
class VHMRegressions(unittest.TestCase): class VHMRegressions(unittest.TestCase):
def setUp(self): def setUp(self):
import transaction
from Testing.makerequest import makerequest
from Testing.ZopeTestCase.ZopeLite import app
transaction.begin() transaction.begin()
self.app = makerequest(Zope2.app()) self.app = makerequest(app())
try: if 'virtual_hosting' not in self.app.objectIds():
if not hasattr(self.app, 'virtual_hosting'): # If ZopeLite was imported, we have no default virtual
# If ZopeLite was imported, we have no default virtual host monster # host monster
from Products.SiteAccess.VirtualHostMonster import manage_addVirtualHostMonster from Products.SiteAccess.VirtualHostMonster \
manage_addVirtualHostMonster(self.app, 'virtual_hosting') import manage_addVirtualHostMonster
self.app.manage_addFolder('folder') manage_addVirtualHostMonster(self.app, 'virtual_hosting')
self.app.folder.manage_addDTMLMethod('doc', '') self.app.manage_addFolder('folder')
self.app.REQUEST.set('PARENTS', [self.app]) self.app.folder.manage_addDTMLMethod('doc', '')
self.traverse = self.app.REQUEST.traverse self.app.REQUEST.set('PARENTS', [self.app])
except: self.traverse = self.app.REQUEST.traverse
self.tearDown()
def tearDown(self): def tearDown(self):
import transaction
transaction.abort() transaction.abort()
self.app._p_jar.close() self.app._p_jar.close()
...@@ -61,14 +53,26 @@ class VHMRegressions(unittest.TestCase): ...@@ -61,14 +53,26 @@ class VHMRegressions(unittest.TestCase):
def test_actual_url(self): def test_actual_url(self):
self.app.folder.manage_addDTMLMethod('index_html', '') 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'
ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/doc') '/folder/VirtualHostRoot/doc/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://www.mysite.com/doc') self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot/') 'http://www.mysite.com/doc/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://www.mysite.com/')
ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/VirtualHostRoot') ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80'
self.assertEqual(self.app.REQUEST['ACTUAL_URL'], 'http://www.mysite.com/') '/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(): def gen_cases():
for vbase, ubase in ( for vbase, ubase in (
...@@ -174,7 +178,3 @@ def test_suite(): ...@@ -174,7 +178,3 @@ def test_suite():
suite.addTest(unittest.makeSuite(VHMRegressions)) suite.addTest(unittest.makeSuite(VHMRegressions))
suite.addTest(unittest.makeSuite(VHMAddingTests)) suite.addTest(unittest.makeSuite(VHMAddingTests))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment