Commit dc4d7d1a authored by Tino Wildenhain's avatar Tino Wildenhain

add virtual_hosting on application initialization - like in 2.7 head

parent 1297a56f
......@@ -291,7 +291,7 @@ class AppInitializer:
def commit(self, note):
get_transaction().note(note)
get_transaction().commit()
def initialize(self):
app = self.getApp()
# make sure to preserve relative ordering of calls below.
......@@ -303,8 +303,9 @@ class AppInitializer:
self.install_zglobals()
self.install_inituser()
self.install_errorlog()
self.install_products()
self.install_products()
self.install_standards()
self.install_virtual_hosting()
self.check_zglobals()
def install_cp_and_products(self):
......@@ -316,7 +317,7 @@ class AppInitializer:
cpl._init()
app._setObject('Control_Panel', cpl)
self.commit('Added Control_Panel')
# b/c: Ensure that a ProductFolder exists.
if not hasattr(aq_base(app.Control_Panel), 'Products'):
app.Control_Panel.Products=App.Product.ProductFolder()
......@@ -378,7 +379,7 @@ class AppInitializer:
default_limit = 1000
default_period_secs = 20
default_timeout_mins = 20
limit = (getattr(config, 'maximum_number_of_session_objects', None)
or default_limit)
timeout_spec = getattr(config, 'session_timeout_minutes',
......@@ -452,7 +453,7 @@ class AppInitializer:
def install_required_roles(self):
app = self.getApp()
# Ensure that Owner role exists.
if hasattr(app, '__ac_roles__') and not ('Owner' in app.__ac_roles__):
app.__ac_roles__=app.__ac_roles__ + ('Owner',)
......@@ -498,6 +499,18 @@ class AppInitializer:
app._setInitializerFlag('error_log')
self.commit('Added site error_log at /error_log')
def install_virtual_hosting(self):
app = self.getApp()
if app._getInitializerFlag('virtual_hosting'):
return
if not app.objectIds('Virtual Host Monster') and not hasattr(app, 'virtual_hosting'):
from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
vhm=VirtualHostMonster()
vhm.id='virtual_hosting'
vhm.addToContainer(app)
app._setInitializerFlag('virtual_hosting')
self.commit('Added virtual_hosting')
def check_zglobals(self):
if not doInstall():
return
......@@ -611,7 +624,7 @@ def get_products():
os.path.exists(os.path.join(fullpath, '__init__.pyo')) or
os.path.exists(os.path.join(fullpath, '__init__.pyc')) ):
# import PluginIndexes 1st (why?)
priority = (name != 'PluginIndexes')
priority = (name != 'PluginIndexes')
# i is used as sort ordering in case a conflict exists
# between Product names. Products will be found as
# per the ordering of Products.__path__
......
......@@ -109,7 +109,7 @@ class TestInitialization( unittest.TestCase ):
self.assertEqual(app.temp_folder.session_data.meta_type,
'Transient Object Container')
self.failUnless(app._getInitializerFlag('temp_folder'))
def test_install_tempfolder_and_sdc_status(self):
self.configure(good_cfg)
i = self.getOne()
......@@ -129,6 +129,14 @@ class TestInitialization( unittest.TestCase ):
self.assertEqual(app.browser_id_manager.meta_type,'Browser Id Manager')
self.failUnless(app._getInitializerFlag('browser_id_manager'))
def test_install_virtual_hosting(self):
self.configure(good_cfg)
i = self.getOne()
app = i.getApp()
i.install_virtual_hosting()
self.assertEqual(app.virtual_hosting.meta_type,'Virtual Host Monster')
self.failUnless(app._getInitializerFlag('virtual_hosting'))
def test_install_session_data_manager(self):
self.configure(good_cfg)
i = self.getOne()
......@@ -154,7 +162,7 @@ class TestInitialization( unittest.TestCase ):
root = i.getApp()._p_jar.root()
self.failUnless(root.has_key('ZGlobals'))
self.failUnless(isinstance(root['ZGlobals'], OOBTree))
def test_install_inituser(self):
fname = os.path.join(TEMPNAME, 'inituser')
f = open(fname, 'w')
......@@ -183,7 +191,7 @@ class TestInitialization( unittest.TestCase ):
i = self.getOne()
i.install_products()
self.failUnless(Application.misc_.__dict__.has_key('OFSP'))
def test_install_standards(self):
self.configure(good_cfg)
i = self.getOne()
......
"""Virtual Host Monster regression tests.
These tests mainly verify that OFS.Traversable.absolute_url()
These tests mainly verify that OFS.Traversable.absolute_url()
works correctly in a VHM environment.
Also see http://zope.org/Collectors/Zope/809
......@@ -26,7 +26,8 @@ class VHMRegressions(unittest.TestCase):
transaction.begin()
self.app = makerequest(Zope.app())
try:
self.app.manage_addProduct['SiteAccess'].manage_addVirtualHostMonster('VHM')
#self.app.manage_addProduct['SiteAccess'].manage_addVirtualHostMonster('VHM')
# now we have a VHM as virtual_hosting per default
self.app.manage_addFolder('folder')
self.app.folder.manage_addDTMLMethod('doc', '')
self.app.REQUEST.set('PARENTS', [self.app])
......
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