def _set_wsgi_config(configfile=None): """ Configure a Zope instance based on ZopeWSGIOptions. Optionally accept a configfile argument (string path) in order to specify where the configuration file exists. """ from Zope2.Startup import options, handlers opts = options.ZopeWSGIOptions(configfile=configfile)() handlers.handleWSGIConfig(opts.configroot, opts.confighandlers) import App.config App.config.setConfiguration(opts.configroot) return opts
def get_app(self, config_file=None): # given a config file, return a Zope application object if config_file is None: config_file = self.get_zope_conf() from Zope2.Startup import options, handlers import App.config import Zope2 opts = options.ZopeWSGIOptions(configfile=config_file)() handlers.handleWSGIConfig(opts.configroot, opts.confighandlers) App.config.setConfiguration(opts.configroot) app = Zope2.app() return app
def test_webdav_source_port(self): conf, handler = self.load_config_text(u"""\ instancehome <<INSTANCE_HOME>> """) handleWSGIConfig(None, handler) self.assertEqual(conf.webdav_source_port, 0) conf, handler = self.load_config_text(u"""\ instancehome <<INSTANCE_HOME>> webdav-source-port 9800 """) handleWSGIConfig(None, handler) self.assertEqual(conf.webdav_source_port, 9800)
def make_wsgi_app(global_config, zope_conf): from App.config import setConfiguration from Zope2.Startup import get_wsgi_starter from Zope2.Startup.handlers import handleWSGIConfig from Zope2.Startup.options import ZopeWSGIOptions from ZPublisher.WSGIPublisher import publish_module starter = get_wsgi_starter() opts = ZopeWSGIOptions(configfile=zope_conf)() if 'debug_mode' in global_config: if global_config['debug_mode'] in ('true', 'on', '1'): opts.configroot.debug_mode = True handleWSGIConfig(opts.configroot, opts.confighandlers) setConfiguration(opts.configroot) starter.setConfiguration(opts.configroot) starter.prepare() return publish_module
def test_automatically_quote_dtml_request_data(self): conf, handler = self.load_config_text("""\ instancehome <<INSTANCE_HOME>> """) handleWSGIConfig(None, handler) self.assertTrue(conf.automatically_quote_dtml_request_data) self.assertEqual(os.environ.get('ZOPE_DTML_REQUEST_AUTOQUOTE', ''), '') conf, handler = self.load_config_text("""\ instancehome <<INSTANCE_HOME>> automatically-quote-dtml-request-data off """) handleWSGIConfig(None, handler) self.assertFalse(conf.automatically_quote_dtml_request_data) self.assertEqual(os.environ.get('ZOPE_DTML_REQUEST_AUTOQUOTE', ''), '0')
def test_ms_public_header(self): import webdav default_setting = webdav.enable_ms_public_header try: conf, handler = self.load_config_text("""\ instancehome <<INSTANCE_HOME>> enable-ms-public-header true """) handleWSGIConfig(None, handler) self.assertTrue(webdav.enable_ms_public_header) conf, handler = self.load_config_text("""\ instancehome <<INSTANCE_HOME>> enable-ms-public-header false """) handleWSGIConfig(None, handler) self.assertFalse(webdav.enable_ms_public_header) finally: webdav.enable_ms_public_header = default_setting