summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjortel <devnull@localhost>2010-03-11 21:24:20 +0000
committerjortel <devnull@localhost>2010-03-11 21:24:20 +0000
commit4123470f3cfd1e6ff3e07214f08e9fdf7c0258c3 (patch)
treeceaddc08301e8837e7993ec3c24fbe4f0f97c078
parentc51561c339bcf56e2039c51d7db9457e8d76eb7c (diff)
downloadsuds-4123470f3cfd1e6ff3e07214f08e9fdf7c0258c3.tar.gz
Fix Timezone.local references; Change xsd.sxbasic.qualify() to use the schema tns when the document default namespace is not specified (None, None). This handles poorly written wsdl/schema files that contain unqualified references such as: base='Animal' but don't define a default namespace for the schema document. The expectation here (although incorrect) is that the schema tns be used.
-rw-r--r--suds/__init__.py2
-rw-r--r--suds/sax/__init__.py4
-rw-r--r--suds/sax/date.py23
-rw-r--r--suds/xsd/sxbase.py8
-rw-r--r--tests/builtin.py56
5 files changed, 53 insertions, 40 deletions
diff --git a/suds/__init__.py b/suds/__init__.py
index c1d249a..1f61fc5 100644
--- a/suds/__init__.py
+++ b/suds/__init__.py
@@ -27,7 +27,7 @@ import sys
#
__version__ = '0.4'
-__build__="(beta) R663-20100303"
+__build__="(beta) R665-20100311"
#
# Exceptions
diff --git a/suds/sax/__init__.py b/suds/sax/__init__.py
index b4d343e..3d71432 100644
--- a/suds/sax/__init__.py
+++ b/suds/sax/__init__.py
@@ -69,6 +69,10 @@ class Namespace:
return (p, u)
@classmethod
+ def none(cls, ns):
+ return ( ns == cls.default )
+
+ @classmethod
def xsd(cls, ns):
try:
return cls.w3(ns) and ns[1].endswith('XMLSchema')
diff --git a/suds/sax/date.py b/suds/sax/date.py
index 81a7a10..b564d9a 100644
--- a/suds/sax/date.py
+++ b/suds/sax/date.py
@@ -120,6 +120,8 @@ class Time:
- HH:MI:SS.ms(z|Z)
- HH:MI:SS(+|-)06:00
- HH:MI:SS.ms(+|-)06:00
+ @ivar tz: The timezone
+ @type tz: L{Timezone}
@ivar date: The object value.
@type date: B{datetime}.I{time}
"""
@@ -181,8 +183,7 @@ class Time:
"""
if hasattr(self, 'offset'):
today = dt.date.today()
- tz = Timezone()
- delta = Timezone.adjustment(self.offset)
+ delta = self.tz.adjustment(self.offset)
d = dt.datetime.combine(today, self.time)
d = ( d + delta )
self.time = d.time()
@@ -303,8 +304,7 @@ class DateTime(Date,Time):
"""
if not hasattr(self, 'offset'):
return
- tz = Timezone()
- delta = Timezone.adjustment(self.offset)
+ delta = self.tz.adjustment(self.offset)
try:
d = ( self.datetime + delta )
self.datetime = d
@@ -345,9 +345,13 @@ class Timezone:
"""
pattern = re.compile('([zZ])|([\-\+][0-9]{2}:[0-9]{2})')
+
+ LOCAL = ( 0-time.timezone/60/60 )
- def __init__(self):
- self.local = ( 0-time.timezone/60/60 )
+ def __init__(self, offset=None):
+ if offset is None:
+ offset = self.LOCAL
+ self.local = offset
@classmethod
def split(cls, s):
@@ -363,13 +367,12 @@ class Timezone:
return (s,)
x = m.start(0)
return (s[:x], s[x:])
-
- @classmethod
- def adjustment(cls, offset):
+
+ def adjustment(self, offset):
"""
Get the adjustment to the I{local} TZ.
@return: The delta between I{offset} and local TZ.
@rtype: B{datetime}.I{timedelta}
"""
- delta = ( cls.local - offset )
+ delta = ( self.local - offset )
return dt.timedelta(hours=delta)
diff --git a/suds/xsd/sxbase.py b/suds/xsd/sxbase.py
index 9c2cb1f..1c0ba64 100644
--- a/suds/xsd/sxbase.py
+++ b/suds/xsd/sxbase.py
@@ -23,6 +23,7 @@ from logging import getLogger
from suds import *
from suds.xsd import *
from suds.sax.element import Element
+from suds.sax import Namespace
log = getLogger(__name__)
@@ -354,9 +355,14 @@ class SchemaObject(object):
def qualify(self):
"""
Convert attribute values, that are references to other
- objects, into I{qref}.
+ objects, into I{qref}. Qualfied using default document namespace.
+ Since many wsdls are written improperly: when the document does
+ not define a default namespace, the schema target namespace is used
+ to qualify references.
"""
defns = self.root.defaultNamespace()
+ if Namespace.none(defns):
+ defns = self.schema.tns
for a in self.autoqualified():
ref = getattr(self, a)
if ref is None:
diff --git a/tests/builtin.py b/tests/builtin.py
index c8f6c6f..ca6c2e6 100644
--- a/tests/builtin.py
+++ b/tests/builtin.py
@@ -51,7 +51,7 @@ class DateTest(TestCase):
self.equalsTimezone(6)
def testUtcTimezone(self):
- Timezone.local = 0
+ Timezone.LOCAL = 0
ref = dt.date(1941, 12, 7)
s = '%.4d-%.2d-%.2dZ' % (ref.year, ref.month, ref.day)
xdate = Date()
@@ -59,7 +59,7 @@ class DateTest(TestCase):
self.assertEqual(d, ref)
def equalsTimezone(self, tz):
- Timezone.local = tz
+ Timezone.LOCAL = tz
ref = dt.date(1941, 12, 7)
s = '%.4d-%.2d-%.2d%+.2d:00' % (ref.year, ref.month, ref.day, tz)
xdate = Date()
@@ -105,7 +105,7 @@ class TimeTest(TestCase):
self.equalsTimezone(-6)
def testUtcTimezone(self):
- Timezone.local = 0
+ Timezone.LOCAL = 0
ref = dt.time(10, 30, 22)
s = '%.2d:%.2d:%.2dZ' % (ref.hour, ref.minute, ref.second)
xtime = Time()
@@ -113,7 +113,7 @@ class TimeTest(TestCase):
self.assertEqual(t, ref)
def equalsTimezone(self, tz):
- Timezone.local = tz
+ Timezone.LOCAL = tz
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, tz)
xtime = Time()
@@ -121,7 +121,7 @@ class TimeTest(TestCase):
self.assertEqual(t, ref)
def testConvertNegativeToGreaterNegative(self):
- Timezone.local = -6
+ Timezone.LOCAL = -6
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, -5)
xtime = Time()
@@ -131,7 +131,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToLesserNegative(self):
- Timezone.local = -5
+ Timezone.LOCAL = -5
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, -6)
xtime = Time()
@@ -141,7 +141,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToGreaterPositive(self):
- Timezone.local = 3
+ Timezone.LOCAL = 3
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, 2)
xtime = Time()
@@ -151,7 +151,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToLesserPositive(self):
- Timezone.local = 2
+ Timezone.LOCAL = 2
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, 3)
xtime = Time()
@@ -161,7 +161,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToNegative(self):
- Timezone.local = -6
+ Timezone.LOCAL = -6
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, 3)
xtime = Time()
@@ -171,7 +171,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToPositive(self):
- Timezone.local = 3
+ Timezone.LOCAL = 3
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, -6)
xtime = Time()
@@ -181,7 +181,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToUtc(self):
- Timezone.local = 0
+ Timezone.LOCAL = 0
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, -6)
xtime = Time()
@@ -191,7 +191,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToUtc(self):
- Timezone.local = 0
+ Timezone.LOCAL = 0
ref = dt.time(10, 30, 22)
s = self.strTime(ref.hour, ref.minute, ref.second, 3)
xtime = Time()
@@ -201,7 +201,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertUtcToPositive(self):
- Timezone.local = 3
+ Timezone.LOCAL = 3
ref = dt.time(10, 30, 22)
s = '%.2d:%.2d:%.2dZ' % (ref.hour, ref.minute, ref.second)
xtime = Time()
@@ -211,7 +211,7 @@ class TimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertUtcToNegative(self):
- Timezone.local = -6
+ Timezone.LOCAL = -6
ref = dt.time(10, 30, 22)
s = '%.2d:%.2d:%.2dZ' % (ref.hour, ref.minute, ref.second)
xtime = Time()
@@ -273,7 +273,7 @@ class DateTimeTest(TestCase):
self.equalsTimezone(-6)
def testUtcTimezone(self):
- Timezone.local = 0
+ Timezone.LOCAL = 0
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2d' \
% (ref.year,
@@ -287,7 +287,7 @@ class DateTimeTest(TestCase):
self.assertEqual(t, ref)
def equalsTimezone(self, tz):
- Timezone.local = tz
+ Timezone.LOCAL = tz
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -302,7 +302,7 @@ class DateTimeTest(TestCase):
self.assertEqual(t, ref)
def testConvertNegativeToGreaterNegative(self):
- Timezone.local = -6
+ Timezone.LOCAL = -6
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -322,7 +322,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToLesserNegative(self):
- Timezone.local = -5
+ Timezone.LOCAL = -5
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -342,7 +342,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToGreaterPositive(self):
- Timezone.local = 3
+ Timezone.LOCAL = 3
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -362,7 +362,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToLesserPositive(self):
- Timezone.local = 2
+ Timezone.LOCAL = 2
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -382,7 +382,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToNegative(self):
- Timezone.local = -6
+ Timezone.LOCAL = -6
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -402,7 +402,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToPositive(self):
- Timezone.local = 3
+ Timezone.LOCAL = 3
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -422,7 +422,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToUtc(self):
- Timezone.local = 0
+ Timezone.LOCAL = 0
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -442,7 +442,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertPositiveToUtc(self):
- Timezone.local = 0
+ Timezone.LOCAL = 0
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = self.strDateTime(
ref.year,
@@ -462,7 +462,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertUtcToPositive(self):
- Timezone.local = 3
+ Timezone.LOCAL = 3
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ' \
% (ref.year,
@@ -481,7 +481,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertUtcToNegative(self):
- Timezone.local = -6
+ Timezone.LOCAL = -6
ref = dt.datetime(1941, 12, 7, 10, 30, 22)
s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ' \
% (ref.year,
@@ -500,7 +500,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToGreaterNegativeAndPreviousDay(self):
- Timezone.local = -6
+ Timezone.LOCAL = -6
ref = dt.datetime(1941, 12, 7, 0, 30, 22)
s = self.strDateTime(
ref.year,
@@ -520,7 +520,7 @@ class DateTimeTest(TestCase):
self.assertEqual(ref.second, t.second)
def testConvertNegativeToLesserNegativeAndNextDay(self):
- Timezone.local = -5
+ Timezone.LOCAL = -5
ref = dt.datetime(1941, 12, 7, 23, 30, 22)
s = self.strDateTime(
ref.year,