Browse Source

Refactor in order to support dotted parameters

pull/48/head
Nicolas Bessi 10 years ago
parent
commit
269e2ca36f
  1. 18
      server_environment/serv_config.py
  2. 2
      server_environment/system_info.py

18
server_environment/serv_config.py

@ -133,15 +133,16 @@ class ServerConfiguration(models.TransientModel):
def _add_columns(self):
"""Add columns to model dynamically"""
cols = chain(
self._get_base_cols(),
self._get_env_cols(),
self._get_system_cols()
self._get_base_cols().items(),
self._get_env_cols().items(),
self._get_system_cols().items()
)
for col in cols:
print col
for col, value in cols:
col_name = col.replace('.', '_')
setattr(ServerConfiguration,
col,
col_name,
fields.Char(string=col, readonly=True))
self._conf_defaults[col_name] = value
def _get_base_cols(self):
""" Compute base fields"""
@ -152,7 +153,6 @@ class ServerConfiguration(models.TransientModel):
# fld.name = key
# fld.model_name = self._model
res[key] = item
self._conf_defaults[key] = item
return res
def _get_env_cols(self, sections=None):
@ -163,7 +163,6 @@ class ServerConfiguration(models.TransientModel):
for col, item in serv_config.items(section):
key = self._format_key(section, col)
res[key] = item
self._conf_defaults[key] = item
return res
def _get_system_cols(self):
@ -172,7 +171,6 @@ class ServerConfiguration(models.TransientModel):
for col, item in get_server_environment():
key = self._format_key('system', col)
res[key] = item
self._conf_defaults[key] = item
return res
def _group(self, items):
@ -180,7 +178,7 @@ class ServerConfiguration(models.TransientModel):
names = []
for key in sorted(items):
names.append(key)
names.append(key.replace('.', '_'))
return ('<group col="2" colspan="4">' +
''.join(['<field name="%s" readonly="1"/>' %
_escape(name) for name in names]) +

2
server_environment/system_info.py

@ -53,7 +53,7 @@ def get_server_environment():
lsbinfo = 'not lsb compliant'
return (
('platform', platform.platform()),
('os name', os.name),
('os.name', os.name),
('lsb_release', lsbinfo),
('release', platform.release()),
('version', platform.version()),

Loading…
Cancel
Save