ValueError parsing date with negative timezone (w/ fix)
by Grant Kushida
I've run into an ValueError issue when parsing an xsd:date response with
a negative UTC timezone offset. This is happening in suds 0.3.6 as well
as on the trunk.
Sorry I can't provide the WSDL, since this is internal-only - but
instead, I have some patches which fix the issue in sxdate.py, and add
two test cases to builtin.py. If these changes look acceptable I'd
appreciate it if they were integrated into some future Suds version.
The server uses Apache CXF 2.1.1 and JAX-B 2.1.6. The WSDL defines a
response element as follows:
<xsd:element name="startDate" type="xsd:date"/>
The response includes the timezone offset (US Pacific time), which
happens to be negative:
<startDate>2008-01-01-08:00</startDate>
This gives a ValueError exception, similar to the following (this is
actually from the test case I implemented, not the original web service
client where I found the error):
Traceback (most recent call last):
File "tests/builtin.py", line 121, in
test_should_return_correct_date_object_given_date_with_different_negativ
e_timezone
date = XDate().translate("1945-08-20-03:00")
File "<my home dir>/suds/trunk/suds/xsd/sxdate.py", line 82, in
translate
return self.toPython(value)
File "<my home dir>/suds/trunk/suds/xsd/sxdate.py", line 55, in
toPython
year, month, day = value.rsplit('-', 3)
ValueError: too many values to unpack
Here are the diffs from SVN trunk revision 547, for the one-line fix to
sxdate.py and the two testcases added to builtin.py.
Index: tests/builtin.py
===================================================================
--- tests/builtin.py (revision 547)
+++ tests/builtin.py (working copy)
@@ -117,11 +117,25 @@
self.assertEqual(date.second, 0)
self.assertEqual(date.hour, self.getHour(0, 3))
+ def
test_should_return_correct_date_object_given_date_with_different_negativ
e_timezone(self):
+ date = XDate().translate("1945-08-20-03:00")
+ self.assertEqual(date.day, self.getDay(20, 0, -3))
+ self.assertEqual(date.month, 8)
+ self.assertEqual(date.year, 1945)
+ self.assertEqual(date.minute, 0)
+ self.assertEqual(date.second, 0)
+ self.assertEqual(date.hour, self.getHour(0, -3))
+
def
test_should_return_correct_string_from_date_object_given_date_with_timez
one(self):
date = XDate().translate(XDate().translate("1945-08-20+03:00"),
False)
self.assertEquals("1945-08-%s%s" % (str(self.getDay(20, 0, 3)),
self.getTestersTimezoneString()), date)
+ def
test_should_return_correct_string_from_date_object_given_date_with_negat
ive_timezone(self):
+ date = XDate().translate(XDate().translate("1945-08-20-03:00"),
False)
+
+ self.assertEquals("1945-08-%s%s" % (str(self.getDay(20, 0,
-3)), self.getTestersTimezoneString()), date)
+
def
test_should_return_correct_date_object_given_date_with_different_utc(sel
f):
#from where I am, this is 6 hours off and would become a
different day
date = XDate().translate("1945-08-20Z")
Index: suds/xsd/sxdate.py
===================================================================
--- suds/xsd/sxdate.py (revision 547)
+++ suds/xsd/sxdate.py (working copy)
@@ -52,7 +52,7 @@
if len(value) == 0:
return None
- year, month, day = value.rsplit('-', 3)
+ year, month, day = value.split('-', 2)
#if it has a tz set, convert to user's tz
if len(day) > 2:
14 years, 8 months
character
by Close
Ite out of sight. But the Little Sweetheart did not care. In fact, she
had no time to think, for the Queen came sailing in and spoke to her,
and crowds of ladies in dresses so bright and beautiful that they
dazzled her eyes; and the Prince was there kissing her, and in a minute
they were married, and went floating off in a dance, which was so swift
it did not feel so much like dancing as it did like being carried
through the air by a gentle wind. Through room after room,--there seemed
14 years, 8 months
Problem with TypeNotFound
by Andrzej Mleczko
Hi all,
I'm trying to use suds (different versions - latest trunk as well) for one
of my projects. For most use cases it works well, but I cannot use it for
one of the methods from wsdl schema.
I'm getting always TypeNotFound. I was trying to validate my wsdl schema
(pass). I was trying to use wget to pass envolpe - it works OK.
Anybody have a hint? How can I debug it more. The webservice is not public
so I cannot share the xml.
Here is traceback: http://pastie.org/private/lwx5dtvsctrmkisuatfogq
Thanks!
--
Andrew Mleczko
e-mail: andrew(a)mleczko.net
skype: amleczko
14 years, 9 months
Problem with TypeNotFound
by Andrzej.Mleczko@redturtle.net
Hi all,
I'm trying to use suds (different versions - latest trunk as well) for one
of my projects. For most use cases it works well, but I cannot use it for
one of the methods from wsdl schema.
I'm getting always TypeNotFound. I was trying to validate my wsdl schema
(pass). I was trying to use wget to pass envolpe - it works OK.
Anybody have a hint? How can I debug it more. The webservice is not public
so I cannot share the xml.
Here is traceback: http://pastie.org/private/lwx5dtvsctrmkisuatfogq
Thanks!
----------------------------------------------------------
Andrew Mleczko - RedTurtle Technology
E-mail: andrew.mleczko(a)redturtle.net
Web Site: http://www.redturtle.net
Phone: +39 0532 1915958
Mobile: +39 334 7382343
Fax: +39 0532 287070
14 years, 9 months