summaryrefslogtreecommitdiff
path: root/suds
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 /suds
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.
Diffstat (limited to 'suds')
-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
4 files changed, 25 insertions, 12 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: