import os
import sys
import openerp
+import openerp.conf
import openerp.loglevels as loglevels
import logging
import openerp.release as release
self.my_default = attrs.pop('my_default', None)
super(MyOption, self).__init__(*opts, **attrs)
+#.apidoc title: Server Configuration Loader
+
def check_ssl():
try:
from OpenSSL import SSL
group.add_option("-P", "--import-partial", dest="import_partial", my_default='',
help="Use this for big data importation, if it crashes you will be able to continue at the current state. Provide a filename to store intermediate importation states.")
group.add_option("--pidfile", dest="pidfile", help="file where the server pid will be stored")
+ group.add_option("--addons-path", dest="addons_path",
+ help="specify additional addons paths (separated by commas).",
+ action="callback", callback=self._check_addons_path, nargs=1, type="string")
+ group.add_option("--load", dest="server_wide_modules", help="Comma-separated list of server-wide modules default=web")
parser.add_option_group(group)
+ # XML-RPC / HTTP
group = optparse.OptionGroup(parser, "XML-RPC Configuration")
group.add_option("--xmlrpc-interface", dest="xmlrpc_interface", my_default='',
help="Specify the TCP IP address for the XML-RPC protocol. The empty string binds to all interfaces.")
help="disable the XML-RPC protocol")
parser.add_option_group(group)
+ # XML-RPC / HTTPS
title = "XML-RPC Secure Configuration"
if not self.has_ssl:
title += " (disabled as ssl is unavailable)"
help="disable the NETRPC protocol")
parser.add_option_group(group)
+ # WEB
+ # TODO move to web addons after MetaOption merge
+ group = optparse.OptionGroup(parser, "Web interface Configuration")
+ group.add_option("--db-filter", dest="dbfilter", default='.*',
+ help="Filter listed database", metavar="REGEXP")
+ 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", my_default=False, help="enable static HTTP service for serving plain HTML files")
help="overwrites existing translation terms on updating a module or importing a CSV or a PO file.")
group.add_option("--modules", dest="translate_modules",
help="specify modules to export. Use in combination with --i18n-export")
- group.add_option("--addons-path", dest="addons_path",
- help="specify additional addons paths (separated by commas).",
- action="callback", callback=self._check_addons_path, nargs=1, type="string")
parser.add_option_group(group)
security = optparse.OptionGroup(parser, 'Security-related options')
"osv_memory tables. This is a decimal value expressed in hours, "
"and the default is 1 hour.",
type="float")
+ group.add_option("--max-cron-threads", dest="max_cron_threads", my_default=4,
+ help="Maximum number of threads processing concurrently cron jobs.",
+ type="int")
+ group.add_option("--unaccent", dest="unaccent", my_default=False, action="store_true",
+ help="Use the unaccent function provided by the database when available.")
+
parser.add_option_group(group)
# Copy all optparse options (i.e. MyOption) into self.options.
self.options[option.dest] = option.my_default
self.casts[option.dest] = option
- self.parse_config()
+ self.parse_config(None, False)
- def parse_config(self, args=[]):
- opt, args = self.parser.parse_args()
+ def parse_config(self, args=None, complete=True):
+ """ Parse the configuration file (if any) and the command-line
+ arguments.
+
+ This method initializes openerp.tools.config and openerp.conf (the
+ former should be removed in the furture) with library-wide
+ configuration values.
+
+ This method must be called before proper usage of this library can be
+ made.
+
+ Typical usage of this method:
+
+ openerp.tools.config.parse_config(sys.argv[1:])
+
+ :param complete: this is a hack used in __init__(), leave it to True.
+
+ """
+ if args is None:
+ args = []
+ opt, args = self.parser.parse_args(args)
def die(cond, msg):
if cond:
'netrpc_interface', 'netrpc_port', 'db_maxconn', 'import_partial', 'addons_path',
'netrpc', 'xmlrpc', 'syslog', 'without_demo', 'timezone',
'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs',
- 'secure_cert_file', 'secure_pkey_file',
- 'static_http_enable', 'static_http_document_root', 'static_http_url_prefix'
+ 'static_http_enable', 'static_http_document_root', 'static_http_url_prefix',
+ 'secure_cert_file', 'secure_pkey_file', 'dbfilter'
]
for arg in keys:
'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog',
'list_db', 'xmlrpcs',
'test_file', 'test_disable', 'test_commit', 'test_report_directory',
- 'osv_memory_count_limit', 'osv_memory_age_limit',
+ 'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent',
]
for arg in keys:
if opt.save:
self.save()
+ openerp.conf.max_cron_threads = self.options['max_cron_threads']
+
+ openerp.conf.addons_paths = self.options['addons_path'].split(',')
+ if opt.server_wide_modules:
+ openerp.conf.server_wide_modules = map(lambda m: m.strip(), opt.server_wide_modules.split(','))
+ else:
+ openerp.conf.server_wide_modules = ['web']
+ if complete:
+ openerp.modules.module.initialize_sys_path()
+ openerp.modules.loading.open_openerp_namespace()
+ # openerp.addons.__path__.extend(openerp.conf.addons_paths) # This
+ # is not compatible with initialize_sys_path(): import crm and
+ # import openerp.addons.crm load twice the module.
+
def _generate_pgpassfile(self):
"""
Generate the pgpass file with the parameters from the command line (db_host, db_user,
config = configmanager()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: