falc410 / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

problems with datetime.datetime types #154

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have a soap function that expects any datetime.datetime parameters

What is the expected output? What do you see instead?

For me the code broke in two places, once in simplexml.py, once in client.py:

1. client.py line 354: test = master(test)
-> master is an object type(datetime.datetime)
-> test is the actual object datetime.datetime
master(test) => errormessage: ValueError: Invalid Args Structure. Errors: 
[u"type mismatch for value. master(<type 'type'>): <type 'datetime.datetime'>, 
test(<type 'datetime.datetime'>): 2014-08-01 00:00:00"]
fix => first test if type(test) is not master, only then try the cast
so from line 350 (might be a naive approach, works for my problem now):
if isinstance(master, type) or masterisclass:
    # first test the type, only if that is not ok...
    if type(test) is not master:
        # ...attempt to cast input to master type
        try:
            test = master(test)
        except:
            valid = False
            errors.append('type mismatch for value. master(%s): %s, test(%s): %s' % (type(master), master, type(test), test))

2. simplexml.py line 62: datetime_m = lambda dt: dt.isoformat('T') 
=> errormessage: TypeError: isoformat() argument 1 must be char, not unicode
=> fix: datetime_m = lambda dt: dt.isoformat(str('T'))

What version of the product are you using? On what operating system?
PySimpleSOAP 1.10, python 2.7.7, Windows 8.1

Original issue reported on code.google.com by oliver.s...@gmail.com on 2 Sep 2014 at 8:33