1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 Provides typed unmarshaller classes.
19 """
20
21 from logging import getLogger
22 from suds import *
23 from suds.umx import *
24 from suds.umx.core import Core
25 from suds.resolver import NodeResolver, Frame
26 from suds.sudsobject import Factory
27
28 log = getLogger(__name__)
29
30
31
32
33
34
35
36 Content.extensions.append('type')
37 Content.extensions.append('real')
38
39
41 """
42 A I{typed} XML unmarshaller
43 @ivar resolver: A schema type resolver.
44 @type resolver: L{NodeResolver}
45 """
46
53
55 """
56 Process an object graph representation of the xml L{node}.
57 @param node: An XML tree.
58 @type node: L{sax.element.Element}
59 @param type: The I{optional} schema type.
60 @type type: L{xsd.sxbase.SchemaObject}
61 @return: A suds object.
62 @rtype: L{Object}
63 """
64 content = Content(node)
65 content.type = type
66 return Core.process(self, content)
67
71
72 - def start(self, content):
94
95 - def end(self, content):
97
100
105
107 """
108 Append an attribute name/value into L{Content.data}.
109 @param name: The attribute name
110 @type name: basestring
111 @param value: The attribute's value
112 @type value: basestring
113 @param content: The current content being unmarshalled.
114 @type content: L{Content}
115 """
116 type = self.resolver.findattr(name)
117 if type is None:
118 log.warn('attribute (%s) type, not-found', name)
119 else:
120 value = self.translated(value, type)
121 Core.append_attribute(self, name, value, content)
122
123 - def append_text(self, content):
124 """
125 Append text nodes into L{Content.data}
126 Here is where the I{true} type is used to translate the value
127 into the proper python type.
128 @param content: The current content being unmarshalled.
129 @type content: L{Content}
130 """
131 Core.append_text(self, content)
132 known = self.resolver.top().resolved
133 content.text = self.translated(content.text, known)
134
136 """ translate using the schema type """
137 if value is not None:
138 resolved = type.resolve()
139 return resolved.translate(value)
140 else:
141 return value
142