Merge lp:~j-launchpad-dennis/ladon/xsddatetime into lp:ladon

Proposed by Dennis Plöger
Status: Needs review
Proposed branch: lp:~j-launchpad-dennis/ladon/xsddatetime
Merge into: lp:ladon
Diff against target: 58 lines (+23/-1)
2 files modified
frameworks/python/src/ladon/compat.py (+3/-1)
frameworks/python/src/ladon/types/typeconverter.py (+20/-0)
To merge this branch: bzr merge lp:~j-launchpad-dennis/ladon/xsddatetime
Reviewer Review Type Date Requested Status
Ladon Developer Pending
Review via email: mp+190078@code.launchpad.net

Description of the change

Add support for xsd:DateTime in SOAP-requests

To post a comment you must log in.

Unmerged revisions

107. By Dennis Ploeger <email address hidden>

Added xsd:dateTime-Support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'frameworks/python/src/ladon/compat.py'
--- frameworks/python/src/ladon/compat.py 2011-08-22 00:44:05 +0000
+++ frameworks/python/src/ladon/compat.py 2013-10-09 10:19:56 +0000
@@ -1,5 +1,6 @@
1import sys1import sys
2from ladon.types.attachment import attachment2from ladon.types.attachment import attachment
3from datetime import datetime
34
4if sys.version_info[0]==2:5if sys.version_info[0]==2:
5 import StringIO,cStringIO6 import StringIO,cStringIO
@@ -27,7 +28,8 @@
27 unicode: 'string',28 unicode: 'string',
28 bool: 'boolean',29 bool: 'boolean',
29 float: 'decimal',30 float: 'decimal',
30 attachment: 'binary'31 attachment: 'binary',
32 datetime: 'dateTime'
31 }33 }
3234
33 type_to_jsontype = {35 type_to_jsontype = {
3436
=== modified file 'frameworks/python/src/ladon/types/typeconverter.py'
--- frameworks/python/src/ladon/types/typeconverter.py 2012-05-04 14:43:58 +0000
+++ frameworks/python/src/ladon/types/typeconverter.py 2013-10-09 10:19:56 +0000
@@ -2,6 +2,8 @@
2import sys2import sys
3from ladon.exceptions.types import *3from ladon.exceptions.types import *
4from ladon.compat import PORTABLE_BYTES,PORTABLE_STRING,pytype_support,safe_conversions4from ladon.compat import PORTABLE_BYTES,PORTABLE_STRING,pytype_support,safe_conversions
5from datetime import dateime,tzinfo
6import re
57
6class TypeConverter(object):8class TypeConverter(object):
7 9
@@ -59,6 +61,24 @@
59 try:61 try:
60 if typ==bool and (val[0].upper()==PORTABLE_STRING('F') or val.strip()=='0'):62 if typ==bool and (val[0].upper()==PORTABLE_STRING('F') or val.strip()=='0'):
61 val = False63 val = False
64 elif typ==datetime:
65 xsd_type = re.match('(?P<year>[\d]{4})-(?P<month>[\d]{2})-(?P<day>[\d]{2})T(?P<hour>[\d]{2}):(?P<minute>[\d]{2}):(?P<second>[\d]{2})(?P<tz>Z|[+-][\d]{2}:[\d]{2})', val)
66 if xsd_type:
67 xsd_type = xsd_type.groupdict()
68 tz = None
69 if xsd_type['tz'] != 'Z':
70 (hours, minutes) = xsd_type['tz'].split(":")
71 tz = tzinfo.utcoffset(int(hours) * 60 + int(minutes))
72 val = datetime(
73 int(xsd_type['year']),
74 int(xsd_type['month']),
75 int(xsd_type['day']),
76 int(xsd_type['hour']),
77 int(xsd_type['minute']),
78 int(xsd_type['second']),
79 0,
80 tz
81 )
62 else:82 else:
63 val = typ(val)83 val = typ(val)
64 # Run incoming filters aka. incoming postfilters84 # Run incoming filters aka. incoming postfilters

Subscribers

People subscribed via source and target branches