[REF] config: rationalized config parameters to make consistent for v6.
Renamed parameters for static HTTP service + improved param check message. + minor cleanup in config params bzr revid: odo@openerp.com-20100810131200-p71zge94l1qp1s18
This commit is contained in:
parent
3a7ce56b57
commit
891eb265b6
|
@ -129,8 +129,8 @@ class SecureMultiHandler2(HttpLogHandler, SecureMultiHTTPHandler):
|
||||||
|
|
||||||
def getcert_fnames(self):
|
def getcert_fnames(self):
|
||||||
tc = tools.config
|
tc = tools.config
|
||||||
fcert = tc.get_misc('httpsd','sslcert', 'ssl/server.cert')
|
fcert = tc.get('secure_cert_file', 'server.cert')
|
||||||
fkey = tc.get_misc('httpsd','sslkey', 'ssl/server.key')
|
fkey = tc.get('secure_pkey_file', 'server.key')
|
||||||
return (fcert,fkey)
|
return (fcert,fkey)
|
||||||
|
|
||||||
class BaseHttpDaemon(threading.Thread, netsvc.Server):
|
class BaseHttpDaemon(threading.Thread, netsvc.Server):
|
||||||
|
@ -304,9 +304,9 @@ class StaticHTTPHandler(HttpLogHandler, FixSendError, HttpOptions, HTTPHandler):
|
||||||
|
|
||||||
def __init__(self,request, client_address, server):
|
def __init__(self,request, client_address, server):
|
||||||
HTTPHandler.__init__(self,request,client_address,server)
|
HTTPHandler.__init__(self,request,client_address,server)
|
||||||
dir_path = tools.config.get_misc('static-http', 'dir_path', False)
|
document_root = tools.config.get('static_http_document_root', False)
|
||||||
assert dir_path, "Please specify static-http/dir_path in config, or disable static-httpd!"
|
assert document_root, "Please specify static_http_document_root in configuration, or disable static-httpd!"
|
||||||
self.__basepath = dir_path
|
self.__basepath = document_root
|
||||||
|
|
||||||
def translate_path(self, path):
|
def translate_path(self, path):
|
||||||
"""Translate a /-separated PATH to the local filename syntax.
|
"""Translate a /-separated PATH to the local filename syntax.
|
||||||
|
@ -329,18 +329,18 @@ class StaticHTTPHandler(HttpLogHandler, FixSendError, HttpOptions, HTTPHandler):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def init_static_http():
|
def init_static_http():
|
||||||
if not tools.config.get_misc('static-http','enable', False):
|
if not tools.config.get('static_http_enable', False):
|
||||||
return
|
return
|
||||||
|
|
||||||
dir_path = tools.config.get_misc('static-http', 'dir_path', False)
|
document_root = tools.config.get('static_http_document_root', False)
|
||||||
assert dir_path
|
assert document_root, "Document root must be specified explicitly to enable static HTTP service (option --static-http-document-root)"
|
||||||
|
|
||||||
base_path = tools.config.get_misc('static-http', 'base_path', '/')
|
base_path = tools.config.get('static_http_url_prefix', '/')
|
||||||
|
|
||||||
reg_http_service(HTTPDir(base_path,StaticHTTPHandler))
|
reg_http_service(HTTPDir(base_path,StaticHTTPHandler))
|
||||||
|
|
||||||
logging.getLogger("web-services").info("Registered HTTP dir %s for %s" % \
|
logging.getLogger("web-services").info("Registered HTTP dir %s for %s" % \
|
||||||
(dir_path, base_path))
|
(document_root, base_path))
|
||||||
|
|
||||||
class OerpAuthProxy(AuthProxy):
|
class OerpAuthProxy(AuthProxy):
|
||||||
""" Require basic authentication..
|
""" Require basic authentication..
|
||||||
|
|
|
@ -85,6 +85,9 @@ class configmanager(object):
|
||||||
'test-file' : False,
|
'test-file' : False,
|
||||||
'test-disable' : False,
|
'test-disable' : False,
|
||||||
'test-commit' : False,
|
'test-commit' : False,
|
||||||
|
'static_http_enable': False,
|
||||||
|
'static_http_document_root': None,
|
||||||
|
'static_http_url_prefix': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.misc = {}
|
self.misc = {}
|
||||||
|
@ -120,12 +123,20 @@ class configmanager(object):
|
||||||
group.add_option("--pkey-file", dest="secure_pkey_file", default="server.pkey", help="specify the private key file for the SSL connection")
|
group.add_option("--pkey-file", dest="secure_pkey_file", default="server.pkey", help="specify the private key file for the SSL connection")
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
|
# NET-RPC
|
||||||
group = optparse.OptionGroup(parser, "NET-RPC Configuration")
|
group = optparse.OptionGroup(parser, "NET-RPC Configuration")
|
||||||
group.add_option("--netrpc-interface", dest="netrpc_interface", help="specify the TCP IP address for the NETRPC protocol")
|
group.add_option("--netrpc-interface", dest="netrpc_interface", help="specify the TCP IP address for the NETRPC protocol")
|
||||||
group.add_option("--netrpc-port", dest="netrpc_port", help="specify the TCP port for the NETRPC protocol", type="int")
|
group.add_option("--netrpc-port", dest="netrpc_port", help="specify the TCP port for the NETRPC protocol", type="int")
|
||||||
group.add_option("--no-netrpc", dest="netrpc", action="store_false", help="disable the NETRPC protocol")
|
group.add_option("--no-netrpc", dest="netrpc", action="store_false", help="disable the NETRPC protocol")
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
|
# Static HTTP
|
||||||
|
group = optparse.OptionGroup(parser, "Static HTTP service")
|
||||||
|
group.add_option("--static-http-enable", dest="static_http_enable", action="store_true", default=False, help="enable static HTTP service for serving plain HTML files")
|
||||||
|
group.add_option("--static-http-document-root", dest="static_http_document_root", help="specify the directory containing your static HTML files (e.g '/var/www/')")
|
||||||
|
group.add_option("--static-http-url-prefix", dest="static_http_url_prefix", help="specify the URL root prefix where you want web browsers to access your static HTML files (e.g '/')")
|
||||||
|
parser.add_option_group(group)
|
||||||
|
|
||||||
parser.add_option("-i", "--init", dest="init", help="init a module (use \"all\" for all modules)")
|
parser.add_option("-i", "--init", dest="init", help="init a module (use \"all\" for all modules)")
|
||||||
parser.add_option("--without-demo", dest="without_demo",
|
parser.add_option("--without-demo", dest="without_demo",
|
||||||
help="load demo data for a module (use \"all\" for all modules)", default=False)
|
help="load demo data for a module (use \"all\" for all modules)", default=False)
|
||||||
|
@ -144,10 +155,10 @@ class configmanager(object):
|
||||||
|
|
||||||
# Testing Group
|
# Testing Group
|
||||||
group = optparse.OptionGroup(parser, "Testing Configuration")
|
group = optparse.OptionGroup(parser, "Testing Configuration")
|
||||||
group.add_option("--test-file", dest="test_file", help="Launch a YML test file.")
|
group.add_option("--test-file", dest="test-file", help="Launch a YML test file.")
|
||||||
group.add_option("--test-disable", action="store_true", dest="test_disable",
|
group.add_option("--test-disable", action="store_true", dest="test-disable",
|
||||||
default=False, help="Disable loading test files.")
|
default=False, help="Disable loading test files.")
|
||||||
group.add_option("--test-commit", action="store_true", dest="test_commit",
|
group.add_option("--test-commit", action="store_true", dest="test-commit",
|
||||||
default=False, help="Commit database changes performed by tests.")
|
default=False, help="Commit database changes performed by tests.")
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
|
@ -261,7 +272,8 @@ class configmanager(object):
|
||||||
'netrpc_interface', 'netrpc_port', 'db_maxconn', 'import_partial', 'addons_path',
|
'netrpc_interface', 'netrpc_port', 'db_maxconn', 'import_partial', 'addons_path',
|
||||||
'netrpc', 'xmlrpc', 'syslog', 'without_demo', 'timezone',
|
'netrpc', 'xmlrpc', 'syslog', 'without_demo', 'timezone',
|
||||||
'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs',
|
'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs',
|
||||||
'secure_cert_file', 'secure_pkey_file'
|
'secure_cert_file', 'secure_pkey_file',
|
||||||
|
'static_http_enable', 'static_http_document_root', 'static_http_url_prefix'
|
||||||
]
|
]
|
||||||
|
|
||||||
for arg in keys:
|
for arg in keys:
|
||||||
|
@ -270,9 +282,9 @@ class configmanager(object):
|
||||||
|
|
||||||
keys = ['language', 'translate_out', 'translate_in', 'debug_mode',
|
keys = ['language', 'translate_out', 'translate_in', 'debug_mode',
|
||||||
'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog',
|
'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog',
|
||||||
'list_db', 'server_actions_allow_code']
|
'list_db', 'server_actions_allow_code', 'xmlrpcs',
|
||||||
|
'test-file', 'test-disable', 'test-commit'
|
||||||
keys.append('xmlrpcs')
|
]
|
||||||
|
|
||||||
for arg in keys:
|
for arg in keys:
|
||||||
if getattr(opt, arg) is not None:
|
if getattr(opt, arg) is not None:
|
||||||
|
@ -295,11 +307,7 @@ class configmanager(object):
|
||||||
|
|
||||||
self.options['init'] = opt.init and dict.fromkeys(opt.init.split(','), 1) or {}
|
self.options['init'] = opt.init and dict.fromkeys(opt.init.split(','), 1) or {}
|
||||||
self.options["demo"] = not opt.without_demo and self.options['init'] or {}
|
self.options["demo"] = not opt.without_demo and self.options['init'] or {}
|
||||||
self.options["test-file"] = opt.test_file
|
|
||||||
self.options["test-disable"] = opt.test_disable
|
|
||||||
self.options["test-commit"] = opt.test_commit
|
|
||||||
self.options['update'] = opt.update and dict.fromkeys(opt.update.split(','), 1) or {}
|
self.options['update'] = opt.update and dict.fromkeys(opt.update.split(','), 1) or {}
|
||||||
|
|
||||||
self.options['translate_modules'] = opt.translate_modules and map(lambda m: m.strip(), opt.translate_modules.split(',')) or ['all']
|
self.options['translate_modules'] = opt.translate_modules and map(lambda m: m.strip(), opt.translate_modules.split(',')) or ['all']
|
||||||
self.options['translate_modules'].sort()
|
self.options['translate_modules'].sort()
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ demo = {}
|
||||||
addons_path = None
|
addons_path = None
|
||||||
reportgz = False
|
reportgz = False
|
||||||
|
|
||||||
[static-http]
|
; Static http parameters
|
||||||
enable = False
|
static_http_enable = False
|
||||||
dir_path = /var/www/html
|
static_http_document_root = /var/www/html
|
||||||
|
static_http_url_prefix = /
|
Loading…
Reference in New Issue