Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2pext
plugin_dbui
Commits
51896bb9
Commit
51896bb9
authored
9 years ago
by
LE GAC Renaud
Browse files
Options
Downloads
Plain Diff
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
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Release 0.6.5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/plugin_dbui/converter.py
+21
-6
21 additions, 6 deletions
modules/plugin_dbui/converter.py
with
21 additions
and
6 deletions
modules/plugin_dbui/converter.py
+
21
−
6
View file @
51896bb9
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment