Skip to content
Snippets Groups Projects
Commit 51896bb9 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '3-incompatibility-scheduler' into 'master'

Protect the field default values against callable.

Close #3

See merge request !3
parents 02e48304 30ce3db0
No related branches found
No related tags found
1 merge request!4Release 0.6.5
......@@ -43,6 +43,9 @@ PAGE = 'page'
SUCCESS = 'success'
TOTAL = 'count'
# list of type which can be converted as a JSON string
JSON_TYPES = (bool, dict, float, int, list, long, str, tuple)
# xtype defining linked comboBoxes
X_LINKED_COMBO = ['xcomboboxmaster', 'xcomboboxslave']
......@@ -112,8 +115,13 @@ def _to_field(field, linkedcombo=True, **kwargs):
cfg["fieldLabel"] = str(T(field.label))
# default value
if field.default:
cfg["value"] = field.default
# the default value can be a callable.
# that case makes no sense on the client side
# in addition the JSON dumps will failed
# therefore the default value are limited to types which can be JSONify.
default = field.default
if default and isinstance(default, JSON_TYPES):
cfg["value"] = default
# the checkBox is rendered initially checked
if field.type == 'boolean':
......@@ -758,10 +766,17 @@ def to_model(table):
fieldname = field.name
# the field of the table
# encode field name and define default value
# encode field name
field_cfg = {'name': encode_field(tablename, fieldname)}
if field.default:
field_cfg['defaultValue'] = field.default
# encode the default value
# the default value can be a callable.
# that case makes no sense on the client side
# in addition the JSON dumps will failed
# therefore the default value are limited to types which can be JSONify.
default = field.default
if default and isinstance(default, JSON_TYPES):
field_cfg['defaultValue'] = default
cfg['fields'].append(field_cfg)
......@@ -881,4 +896,4 @@ def to_viewport(**kwargs):
# configuration options from the keyword arguments
cfg.update(kwargs)
return cfg
return cfg
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment