1. Jason Pellerin
  2. scio_pypy

Commits

Jason Pellerin  committed 3dcbd15

Better lookup of substitutionGroup

  • Participants
  • Parent commits 9e747ae
  • Branches default

Comments (0)

Files changed (1)

File scio/client.py

View file
                         else:
                             # substitutionGroups
                             real_cls, real_name = kids_subs.get(name, (None,None))
+                            print name, real_cls, real_name, kids_subs
                             if real_cls:
                                 setattr(self, real_name, real_cls(el))
                                 # FIXME Or for unnamed subelements:
         self._resolve_refs()
 
     def _build_type(self, t, client):
+        parent = None
         name = t.get('name', None)
         if name is None:
             return
             typel = t.find('{%s}simpleType' % NS_XSD)
         force_name = False
         if typel is not None:
+            # this case looks like:
+            # <xs:element name="XXX"><xs:complexType>...
+            # name and other attribs are in parent (t) but
+            # type details are in child (typel)
             force_name = True
+            parent = t
             t = typel
-        self._make_class(client, t, name=name, force_name=force_name)
+        self._make_class(
+            client, t, name=name, force_name=force_name, parent=parent)
 
     def _process_namespaces(self):
         self.nsmap = SOAPNS.copy()
         nsmap = {None: namespace}
         return OutputMessage(name, namespace, nsmap, parts, header_parts)
 
-    def _make_class(self, client, type_, name=None, force_name=False):
+    def _make_class(self, client, type_, name=None, force_name=False,
+                    parent=None):
         client_type = client.type
         prefix = None #self._tns
 
         cls = type(name, bases, data)
 
         # add to substitutionGroup
-        substitutionGroup = (type_.get('substitutionGroup')
-                             or (type_.find('..').get('substitutionGroup')
-                                 if type_.find('..') else None))
+        substitutionGroup = type_.get('substitutionGroup')
+        if parent is not None and not substitutionGroup:
+            substitutionGroup = parent.get('substitutionGroup')
         if substitutionGroup:
             group_cls = self._make_class(
                 client,