Update of /cvsroot/pywebsvcs/zsi/ZSI/generate
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11942/ZSI/generate
Modified Files:
Tag: serialize-dom-scheme
containers.py wsdl2python.py
Log Message:
----------------------------------------------------------------------
Modified Files:
Tag: serialize-dom-scheme
ZSI/TC.py
-- bug fix in QName.
ZSI/generate/containers.py
-- changed "TypesHeaderContainer" made the import a class variable
so I can globally modify it's contents.
ZSI/generate/utility.py
ZSI/generate/wsdl2python.py
No tag
ZSI/wstools/XMLSchema.py
-- changed <xsd:imports> to prevent recursion errors and to
stop unnecessary duplicate XMLSchema objects representing the
same namespace from being created.
----------------------------------------------------------------------
Index: wsdl2python.py
===================================================================
RCS file: /cvsroot/pywebsvcs/zsi/ZSI/generate/Attic/wsdl2python.py,v
retrieving revision 1.1.2.33
retrieving revision 1.1.2.34
diff -u -d -r1.1.2.33 -r1.1.2.34
--- wsdl2python.py 4 Oct 2005 19:29:11 -0000 1.1.2.33
+++ wsdl2python.py 14 Oct 2005 03:15:29 -0000 1.1.2.34
@@ -13,7 +13,7 @@
from ZSI.wstools.WSDLTools import SoapAddressBinding,\
SoapBodyBinding, SoapBinding,MimeContentBinding,\
HttpUrlEncodedBinding
-from ZSI.wstools.XMLSchema import ElementDeclaration, SchemaError
+from ZSI.wstools.XMLSchema import SchemaReader, ElementDeclaration, SchemaError
from ZSI.typeinterpreter import BaseTypeInterpreter
from ZSI.generate import WsdlGeneratorError, Wsdl2PythonError
from containers import *
@@ -151,38 +151,61 @@
self.logger.debug('gatherNamespaces')
self.usedNamespaces = {}
-
- # gather up all the namespaces and their imports
- def GetImports(nsdict):
- for tns,schema in nsdict.items():
- assert tns == schema.getTargetNamespace(), \
- 'expecting key and schema targetNamespace to be equal'
- if schema in self.usedNamespaces.get(tns, []):
- continue
- self.logger.debug(
- '\n\t\timport schema(%s) -- %s' %(hex(id(schema)), tns)
- )
-
- if self.usedNamespaces.has_key(tns) is False:
- self.usedNamespaces[tns] = [schema,]
- elif schema not in self.usedNamespaces[tns]:
- self.usedNamespaces[tns].append(schema)
- else:
- continue
-
- if len(schema._imported_schemas) > 0:
- GetImports(schema._imported_schemas)
-
+#
+# # gather up all the namespaces and their imports
+# def GetImports(nsdict):
+# for tns,schema in nsdict.items():
+# assert tns == schema.getTargetNamespace(), \
+# 'expecting key and schema targetNamespace to be equal'
+# if schema in self.usedNamespaces.get(tns, []):
+# continue
+# self.logger.debug(
+# '\n\t\timport schema(%s) -- %s' %(hex(id(schema)), tns)
+# )
+#
+# if self.usedNamespaces.has_key(tns) is False:
+# self.usedNamespaces[tns] = [schema,]
+# elif schema not in self.usedNamespaces[tns]:
+# self.usedNamespaces[tns].append(schema)
+# else:
+# continue
+#
+# if len(schema._imported_schemas) > 0:
+# GetImports(schema._imported_schemas)
+#
+# for schema in self._wsdl.types.values():
+# self.logger.debug(\
+# '\n\tRegister schema(%s) -- TNS(%s)' %(hex(id(schema)), schema.getTargetNamespace()),
+# )
+# self.usedNamespaces[schema.getTargetNamespace()] = [schema]
+# print "IMPORTS: ", schema._imported_schemas
+# if schema._imported_schemas:
+# GetImports(schema._imported_schemas)
+#
+# # register namespaces with ns alias dict object
+# for k,v in self.usedNamespaces.items():
+# print "USED: ", (k,v)
+# NAD.add(k)
+
+ # Add all schemas defined in wsdl
+ # to used namespace and to the Alias dict
for schema in self._wsdl.types.values():
- self.logger.debug(\
- '\n\tRegister schema(%s) -- TNS(%s)' %(hex(id(schema)), schema.getTargetNamespace()),
- )
- self.usedNamespaces[schema.getTargetNamespace()] = [schema]
- if schema._imported_schemas:
- GetImports(schema._imported_schemas)
-
- # register namespaces with ns alias dict object
- for k,v in self.usedNamespaces.items():
+ tns = schema.getTargetNamespace()
+ self.logger.debug('Register schema(%s) -- TNS(%s)'\
+ %(hex(id(schema)), tns),)
+ if self.usedNamespaces.has_key(tns) is False:
+ self.usedNamespaces[tns] = []
+ self.usedNamespaces[tns].append(schema)
+ NAD.add(tns)
+
+ # Add all xsd:import schema instances
+ # to used namespace and to the Alias dict
+ for k,v in SchemaReader.namespaceToSchema.items():
+ self.logger.debug('Register schema(%s) -- TNS(%s)'\
+ %(hex(id(v)), k),)
+ if self.usedNamespaces.has_key(k) is False:
+ self.usedNamespaces[k] = []
+ self.usedNamespaces[k].append(v)
NAD.add(k)
def writeClient(self, fd, sdClass=None, msg_fd=None, **kw):
Index: containers.py
===================================================================
RCS file: /cvsroot/pywebsvcs/zsi/ZSI/generate/Attic/containers.py,v
retrieving revision 1.1.2.35
retrieving revision 1.1.2.36
diff -u -d -r1.1.2.35 -r1.1.2.36
--- containers.py 4 Oct 2005 19:29:11 -0000 1.1.2.35
+++ containers.py 14 Oct 2005 03:15:29 -0000 1.1.2.36
@@ -745,16 +745,17 @@
class TypesHeaderContainer(TypesContainerBase):
-
+ '''imports for all generated types modules.
+ '''
+ imports = [
+ 'import ZSI',
+ 'import ZSI.TCcompound',
+ 'from ZSI.TC import ElementDeclaration,TypeDefinition',
+ ]
+
def _setContent(self):
-
- imports = [
- 'import ZSI',
- 'import ZSI.TCcompound',
- 'from ZSI.TC import ElementDeclaration,TypeDefinition',
- ]
+ self.writeArray(TypesHeaderContainer.imports)
- self.writeArray(imports)
class NamespaceClassContainerBase(TypesContainerBase):
def __init__(self):
@@ -943,6 +944,10 @@
definition.append('%s%s' %(ID2,el))
definition.append('%sreturn' %ID5)
+ # JRB give pyclass a descriptive name
+ if self.name is not None:
+ definition.append('%s%s.__name__ = "%s_Holder"' %(ID3,self.getPyClass(), self.name))
+
return definition
def nsuriLogic(self):
@@ -1466,8 +1471,14 @@
self.ns = tp.getTargetNamespace()
qName = tp.getAttribute('type')
self.sKlass = BTI.get_typeclass(qName[1], qName[0])
+ self.pyclass = BTI.get_pythontype(None, None, typeclass=self.sKlass)
def _setContent(self):
+ aname = self.getAttributeName(self.name)
+ pyclass = self.pyclass
+
+ # bool cannot be subclassed
+ if pyclass == 'bool': pyclass = 'int'
element = [
'%sclass %s(%s, ElementDeclaration):' % (ID1, self.getClassName(),
@@ -1476,7 +1487,10 @@
'%s%s' % (ID2, self.schemaTag()),
'%s%s' % (ID2, self.simpleConstructor()),
'%skw["pname"] = ("%s","%s")' % (ID3, self.ns, self.name),
- '%skw["aname"] = "%s"' % (ID3, self.getAttributeName(self.name)),
+ '%skw["aname"] = "%s"' % (ID3, aname),
+ '%sclass IHolder(%s): typecode=self' % (ID3, pyclass),
+ '%skw["pyclass"] = IHolder' %(ID3),
+ '%sIHolder.__name__ = "%s_immutable_holder"' %(ID3, aname),
'%s%s' % (ID3, self.simpleConstructor(self.sKlass)),
]
|