Skip to content

Commit 8bf12a9

Browse files
committed
add Decimal support to dyninit
1 parent 1b45425 commit 8bf12a9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spyne/util/dynint.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from spyne import Integer, ModelBase, Date, DateTime, IpAddress
2+
from spyne import D, Integer, ModelBase, Date, DateTime, IpAddress, Decimal
33
from spyne.protocol import ProtocolBase
44
from spyne.util import six
55
from spyne.util.cdict import cdict
@@ -20,6 +20,12 @@
2020
unicode: lambda _: _.strip(),
2121
}),
2222

23+
Decimal: cdict({
24+
int: lambda _: D(_),
25+
bytes: lambda s: None if s.strip() == '' else D(s.strip()),
26+
unicode: lambda s: None if s.strip() == u'' else D(s.strip()),
27+
}),
28+
2329
Integer: cdict({
2430
int: lambda _: _,
2531
bytes: lambda s: None if s.strip() == '' else int(s.strip()),

0 commit comments

Comments
 (0)