Last active
December 25, 2015 01:59
-
-
Save dploeger/6898931 to your computer and use it in GitHub Desktop.
Add xsd:dateTime-arguments for SOAP in Ladon:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In ladon/compat.py: | |
add to first lines: | |
from datetime import datetime | |
and in line #24: | |
type_to_xsd = { | |
int: 'long', | |
long: 'long', | |
str: 'string', | |
unicode: 'string', | |
bool: 'boolean', | |
float: 'decimal', | |
attachment: 'binary', | |
datetime: 'dateTime' | |
} | |
===================== | |
In ladon/types/typeconverter.py | |
add to first lines | |
from datetime import dateime,tzinfo | |
import re | |
and around line #62: | |
if typ==bool and (val[0].upper()==PORTABLE_STRING('F') or val.strip()=='0'): | |
val = False | |
elif typ==datetime: | |
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) | |
if xsd_type: | |
xsd_type = xsd_type.groupdict() | |
tz = None | |
if xsd_type['tz'] != 'Z': | |
(hours, minutes) = xsd_type['tz'].split(":") | |
tz = tzinfo.utcoffset(int(hours) * 60 + int(minutes)) | |
val = datetime( | |
int(xsd_type['year']), | |
int(xsd_type['month']), | |
int(xsd_type['day']), | |
int(xsd_type['hour']), | |
int(xsd_type['minute']), | |
int(xsd_type['second']), | |
0, | |
tz | |
) | |
else: | |
val = typ(val) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Merge request posted:
https://code.launchpad.net/~j-launchpad-dennis/ladon/xsddatetime/+merge/190078