|
@ -21,15 +21,14 @@ |
|
|
|
|
|
|
|
|
import os |
|
|
import os |
|
|
import ConfigParser |
|
|
import ConfigParser |
|
|
|
|
|
|
|
|
from lxml import etree |
|
|
from lxml import etree |
|
|
|
|
|
|
|
|
from osv import osv, fields |
|
|
|
|
|
from tools.config import config as system_base_config |
|
|
|
|
|
|
|
|
from openerp.osv import osv, fields, orm |
|
|
|
|
|
from openerp.tools.config import config as system_base_config |
|
|
|
|
|
|
|
|
from .system_info import get_server_environment |
|
|
from .system_info import get_server_environment |
|
|
|
|
|
|
|
|
import server_environment_files |
|
|
|
|
|
|
|
|
import openerp.addons import server_environment_files |
|
|
_dir = os.path.dirname(server_environment_files.__file__) |
|
|
_dir = os.path.dirname(server_environment_files.__file__) |
|
|
|
|
|
|
|
|
# Same dict as RawConfigParser._boolean_states |
|
|
# Same dict as RawConfigParser._boolean_states |
|
@ -38,8 +37,10 @@ _boolean_states = {'1': True, 'yes': True, 'true': True, 'on': True, |
|
|
|
|
|
|
|
|
if not system_base_config.get('running_env', False): |
|
|
if not system_base_config.get('running_env', False): |
|
|
raise Exception( |
|
|
raise Exception( |
|
|
"The parameter 'running_env' has not be set neither in base config file option -c or in openerprc.\n" |
|
|
|
|
|
"We strongly recommend against using the rc file but instead use an explicit config file with this content:\n" |
|
|
|
|
|
|
|
|
"The parameter 'running_env' has not be set neither in base config " |
|
|
|
|
|
"file option -c or in openerprc.\n" |
|
|
|
|
|
"We strongly recommend against using the rc file but instead use an " |
|
|
|
|
|
"explicit config file with this content:\n" |
|
|
"[options]\nrunning_env = dev" |
|
|
"[options]\nrunning_env = dev" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@ -47,7 +48,8 @@ ck_path = os.path.join(_dir, system_base_config['running_env']) |
|
|
|
|
|
|
|
|
if not os.path.exists(ck_path) : |
|
|
if not os.path.exists(ck_path) : |
|
|
raise Exception( |
|
|
raise Exception( |
|
|
"Provided server environment does not exist, please add a folder %s" % ck_path |
|
|
|
|
|
|
|
|
"Provided server environment does not exist, " |
|
|
|
|
|
"please add a folder %s" % ck_path |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def setboolean(obj, attr, _bool=_boolean_states): |
|
|
def setboolean(obj, attr, _bool=_boolean_states): |
|
@ -78,7 +80,8 @@ def _listconf(env_path): |
|
|
def _load_config(): |
|
|
def _load_config(): |
|
|
"""Load the configuration and return a ConfigParser instance.""" |
|
|
"""Load the configuration and return a ConfigParser instance.""" |
|
|
default = os.path.join(_dir, 'default') |
|
|
default = os.path.join(_dir, 'default') |
|
|
running_env = os.path.join(_dir, system_base_config['running_env']) |
|
|
|
|
|
|
|
|
running_env = os.path.join(_dir, |
|
|
|
|
|
system_base_config['running_env']) |
|
|
if os.path.isdir(default): |
|
|
if os.path.isdir(default): |
|
|
conf_files = _listconf(default) + _listconf(running_env) |
|
|
conf_files = _listconf(default) + _listconf(running_env) |
|
|
else: |
|
|
else: |
|
@ -105,7 +108,7 @@ class _Defaults(dict): |
|
|
return dict.__setitem__(self, key, func) |
|
|
return dict.__setitem__(self, key, func) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ServerConfiguration(osv.osv_memory): |
|
|
|
|
|
|
|
|
class ServerConfiguration(orm.TransientModel): |
|
|
"""Display server configuration.""" |
|
|
"""Display server configuration.""" |
|
|
_name = 'server.config' |
|
|
_name = 'server.config' |
|
|
_columns = {} |
|
|
_columns = {} |
|
@ -116,8 +119,8 @@ class ServerConfiguration(osv.osv_memory): |
|
|
self.running_env = system_base_config['running_env'] |
|
|
self.running_env = system_base_config['running_env'] |
|
|
# Only show passwords in development |
|
|
# Only show passwords in development |
|
|
self.show_passwords = self.running_env in ('dev',) |
|
|
self.show_passwords = self.running_env in ('dev',) |
|
|
|
|
|
self._arch = None |
|
|
self._build_osv() |
|
|
self._build_osv() |
|
|
return res |
|
|
|
|
|
|
|
|
|
|
|
def _group(self, items, prefix): |
|
|
def _group(self, items, prefix): |
|
|
"""Return an XML chunk which represents a group of fields.""" |
|
|
"""Return an XML chunk which represents a group of fields.""" |
|
@ -166,12 +169,20 @@ class ServerConfiguration(osv.osv_memory): |
|
|
arch += '</notebook></form>' |
|
|
arch += '</notebook></form>' |
|
|
self._arch = etree.fromstring(arch) |
|
|
self._arch = etree.fromstring(arch) |
|
|
|
|
|
|
|
|
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): |
|
|
|
|
|
|
|
|
def fields_view_get(self, cr, uid, view_id=None, view_type='form', |
|
|
|
|
|
context=None, toolbar=False, submenu=False): |
|
|
"""Overwrite the default method to render the custom view.""" |
|
|
"""Overwrite the default method to render the custom view.""" |
|
|
res = super(ServerConfiguration, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar) |
|
|
|
|
|
|
|
|
res = super(ServerConfiguration, self).fields_view_get(cr, uid, |
|
|
|
|
|
view_id, |
|
|
|
|
|
view_type, |
|
|
|
|
|
context, |
|
|
|
|
|
toolbar) |
|
|
if view_type == 'form': |
|
|
if view_type == 'form': |
|
|
arch_node = self._arch |
|
|
arch_node = self._arch |
|
|
xarch, xfields = self._view_look_dom_arch(cr, uid, arch_node, view_id, context=context) |
|
|
|
|
|
|
|
|
xarch, xfields = self._view_look_dom_arch(cr, uid, |
|
|
|
|
|
arch_node, |
|
|
|
|
|
view_id, |
|
|
|
|
|
context=context) |
|
|
res['arch'] = xarch |
|
|
res['arch'] = xarch |
|
|
res['fields'] = xfields |
|
|
res['fields'] = xfields |
|
|
return res |
|
|
return res |
|
@ -182,4 +193,3 @@ class ServerConfiguration(osv.osv_memory): |
|
|
for key in self._conf_defaults: |
|
|
for key in self._conf_defaults: |
|
|
res[key] = self._conf_defaults[key]() |
|
|
res[key] = self._conf_defaults[key]() |
|
|
return res |
|
|
return res |
|
|
ServerConfiguration() |
|
|
|