Date and time types not working

Bug #1575287 reported by poofeg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ladon
New
Undecided
Unassigned

Bug Description

There is exception on call soap method with time:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/ladon/types/typeconverter.py", line 63, in from_unicode_string
    val = typ(val)
TypeError: an integer is required (got type str)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/ladon/server/dispatcher.py", line 168, in dispatch_request
    result = self.call_method(method,req_dict,tc,export_dict,log_line)
  File "/usr/lib/python3.4/site-packages/ladon/server/dispatcher.py", line 86, in call_method
    args += [tc.from_unicode_string(val,arg['type'])]
  File "/usr/lib/python3.4/site-packages/ladon/types/typeconverter.py", line 70, in from_unicode_string
    raise FromUnicodeConversionError(typ,str(e),attr_name=attr_name)
ladon.exceptions.types.FromUnicodeConversionError: Failed to convert from unicode string to Ladon supported type: <class 'datetime.date'>
While handling attribute: Nonean integer is required (got type str)

Processing incoming argument: "update_time"

This fix problem:
ladon/types/typeconverter.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 import sys
+import datetime
 from ladon.exceptions.types import *
 from ladon.compat import PORTABLE_BYTES,PORTABLE_STRING,pytype_support,safe_conversions

@@ -59,6 +60,10 @@
                try:
                        if typ==bool and (val[0].upper()==PORTABLE_STRING('F') or val.strip()=='0'):
                                val = False
+ elif typ==datetime.time:
+ val = datetime.datetime.strptime(val, '%H:%M:%S').time()
+ elif typ==datetime.date:
+ val = datetime.datetime.strptime(val, '%Y-%m-%d').date()
                        else:
                                val = typ(val)
                        # Run incoming filters aka. incoming postfilters

Revision history for this message
poofeg (poofeg) wrote :

Fix with isodate module.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.