From: <bov...@us...> - 2006-05-16 03:34:09
|
Revision: 1215 Author: boverhof Date: 2006-05-15 20:34:06 -0700 (Mon, 15 May 2006) ViewCVS: http://svn.sourceforge.net/pywebsvcs/?rev=1215&view=rev Log Message: ----------- M TC.py -- fix for [ 1489129 ] Unexpected subsitution error message generated code adds bases, so .. if issubclass doesn't work, create an instance and try again. Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-05-15 20:23:35 UTC (rev 1214) +++ trunk/zsi/ZSI/TC.py 2006-05-16 03:34:06 UTC (rev 1215) @@ -169,7 +169,7 @@ prefix,typeName = SplitQName(typeName) uri = ps.GetElementNSdict(elt).get(prefix) subclass = SchemaInstanceType.getTypeDefinition(uri, typeName) - if not issubclass(subclass, pyclass): + if not issubclass(subclass, pyclass) and subclass(None) and not issubclass(subclass, pyclass): raise TypeError( 'Substitute Type (%s, %s) is not derived from %s' % (self.type[0], self.type[1], pyclass), ps.Backtrace(elt)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2006-07-27 13:41:03
|
Revision: 1247 Author: cmoad Date: 2006-07-27 06:39:27 -0700 (Thu, 27 Jul 2006) ViewCVS: http://svn.sourceforge.net/pywebsvcs/?rev=1247&view=rev Log Message: ----------- generated code assumes pname is always first arg and AnyType had namespaces as the first arg. Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-07-17 18:32:47 UTC (rev 1246) +++ trunk/zsi/ZSI/TC.py 2006-07-27 13:39:27 UTC (rev 1247) @@ -234,6 +234,8 @@ attrs_aname -- This is variable name to dictionary of attributes encoded -- encoded namespaceURI (specify if use is encoded) ''' + print 'TypeCode', pname + if type(pname) in _seqtypes: self.nspname, self.pname = pname else: @@ -1618,8 +1620,9 @@ type = (SCHEMA.XSD3, 'anyType') logger = _GetLogger('ZSI.TC.AnyType') - def __init__(self, namespaces=['#all'],pname=None, + def __init__(self, pname=None, namespaces=['#all'], minOccurs=1, maxOccurs=1, strip=1, **kw): + print 'AnyType', pname TypeCode.__init__(self, pname=pname, minOccurs=minOccurs, maxOccurs=maxOccurs, **kw) self.namespaces = namespaces This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2006-07-27 13:41:27
|
Revision: 1248 Author: cmoad Date: 2006-07-27 06:41:23 -0700 (Thu, 27 Jul 2006) ViewCVS: http://svn.sourceforge.net/pywebsvcs/?rev=1248&view=rev Log Message: ----------- Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-07-27 13:39:27 UTC (rev 1247) +++ trunk/zsi/ZSI/TC.py 2006-07-27 13:41:23 UTC (rev 1248) @@ -234,8 +234,6 @@ attrs_aname -- This is variable name to dictionary of attributes encoded -- encoded namespaceURI (specify if use is encoded) ''' - print 'TypeCode', pname - if type(pname) in _seqtypes: self.nspname, self.pname = pname else: @@ -1622,7 +1620,6 @@ def __init__(self, pname=None, namespaces=['#all'], minOccurs=1, maxOccurs=1, strip=1, **kw): - print 'AnyType', pname TypeCode.__init__(self, pname=pname, minOccurs=minOccurs, maxOccurs=maxOccurs, **kw) self.namespaces = namespaces This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2006-10-05 17:35:44
|
Revision: 1257 http://svn.sourceforge.net/pywebsvcs/?rev=1257&view=rev Author: boverhof Date: 2006-10-05 10:35:42 -0700 (Thu, 05 Oct 2006) Log Message: ----------- M TC.py -- Changed a few typecode to use "get_name" method. Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-10-05 17:30:11 UTC (rev 1256) +++ trunk/zsi/ZSI/TC.py 2006-10-05 17:35:42 UTC (rev 1257) @@ -531,8 +531,12 @@ name -- element tag objid -- ID type, unique id ''' + if type(name) is tuple: + return name + + ns = self.nspname n = name or self.pname or ('E' + objid) - return n + return ns,n def has_attributes(self): '''Return True if Attributes are declared outside @@ -614,10 +618,10 @@ pyobj -- processed content. ''' objid = _get_idstr(pyobj) - n = name or self.pname or ('E' + objid) + ns,n = self.get_name(name, objid) # nillable - el = elt.createAppendElement(self.nspname, n) + el = elt.createAppendElement(ns, n) if self.nillable is True and pyobj is Nilled: self.serialize_as_nil(el) return None @@ -749,15 +753,18 @@ return objid = _get_idstr(pyobj) - n = self.get_name(name, objid) + ns,n = self.get_name(name, objid) - kw['name'] = n + # setup key word dict + kw['name'] = (ns,n) + kw.setdefault('typed', self.typed) + tc = type(pyobj) self.logger.debug('Any serialize -- %s', tc) if tc in _seqtypes: if self.asarray: - arrElt = elt.createAppendElement(self.nspname, n ) + arrElt = elt.createAppendElement(ns, n) arrElt.setAttributeNS(self.nspname, 'SOAP-ENC:arrayType', "xsd:anyType[" + str(len(pyobj)) + "]" ) a = self.__class__() # instead of = Any() # since this is also used by AnyLax() @@ -769,16 +776,15 @@ serializer.serialize(elt, sw, o, **kw) return elif tc == types.DictType: - el = elt.createAppendElement(self.nspname, n) + el = elt.createAppendElement(ns, n) parentNspname = self.nspname # temporarily clear nspname for dict elements self.nspname = None for o,m in pyobj.items(): - subkw = dict(kw) if type(o) != types.StringType and type(o) != types.UnicodeType: raise Exception, 'Dictionary implementation requires keys to be of type string (or unicode).' %pyobj - subkw['name'] = o - subkw.setdefault('typed', True) - self.serialize(el, sw, m, **subkw) + kw['name'] = o + kw.setdefault('typed', True) + self.serialize(el, sw, m, **kw) # restore nspname self.nspname = parentNspname return @@ -800,7 +806,7 @@ if not serializer: # Last-chance; serialize instances as dictionary if pyobj is None: - self.serialize_as_nil(elt.createAppendElement(self.nspname, n)) + self.serialize_as_nil(elt.createAppendElement(ns, n)) elif type(pyobj) != types.InstanceType: raise EvaluateException('''Any can't serialize ''' + \ repr(pyobj)) @@ -810,19 +816,20 @@ # Try to make the element name self-describing tag = getattr(serializer, 'tag', None) if self.pname is not None: - serializer.nspname = self.nspname - serializer.pname = self.pname + #serializer.nspname = self.nspname + #serializer.pname = self.pname if "typed" not in kw: kw['typed'] = False elif tag: if tag.find(':') == -1: tag = 'SOAP-ENC:' + tag kw['name'] = tag kw['typed'] = False + serializer.unique = self.unique serializer.serialize(elt, sw, pyobj, **kw) # Reset TypeCode - serializer.nspname = None - serializer.pname = None + #serializer.nspname = None + #serializer.pname = None def RegisterType(C, clobber=0, *args, **keywords): @@ -1462,9 +1469,10 @@ Canonicalize(pyobj, sw, unsuppressedPrefixes=unsuppressedPrefixes, comments=self.comments) return + objid = _get_idstr(pyobj) - n = name or self.pname or ('E' + objid) - xmlelt = elt.createAppendElement(self.nspname, n) + ns,n = self.get_name(name, objid) + xmlelt = elt.createAppendElement(ns, n) if type(pyobj) in _stringtypes: self.set_attributes(xmlelt, pyobj) @@ -1477,11 +1485,12 @@ sw.AddCallback(self.cb, pyobj, unsuppressedPrefixes) def cb(self, elt, sw, pyobj, unsuppressedPrefixes=[]): - if sw.Known(pyobj): return + if sw.Known(pyobj): + return + objid = _get_idstr(pyobj) - n = self.pname or ('E' + objid) - - xmlelt = elt.createAppendElement(self.nspname, n) + ns,n = self.get_name(name, objid) + xmlelt = elt.createAppendElement(ns, n) self.set_attribute_id(xmlelt, objid) xmlelt.setAttributeNS(SOAP.ENC, 'encodingStyle', '""') Canonicalize(pyobj, sw, unsuppressedPrefixes=unsuppressedPrefixes, @@ -1985,7 +1994,9 @@ if type(pyobj) not in _seqtypes: raise EvaluateException, 'expecting a list' - el = elt.createAppendElement(self.nspname, self.pname) + objid = _get_idstr(pyobj) + ns,n = self.get_name(name, objid) + el = elt.createAppendElement(ns, n) if self.nillable is True and pyobj is None: self.serialize_as_nil(el) return None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eo...@us...> - 2006-12-04 18:00:07
|
Revision: 1301 http://svn.sourceforge.net/pywebsvcs/?rev=1301&view=rev Author: eolson Date: 2006-12-04 10:00:03 -0800 (Mon, 04 Dec 2006) Log Message: ----------- Readd removed code that extends functionality of RegisterType(). RegisterGeneratedTypesWithMapping() Registers python classes so they can be serialized and parsed as "any". Uses _RegisterTypeWithSchemaAndClass() and _DynamicImport() functions. Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-11-16 20:06:01 UTC (rev 1300) +++ trunk/zsi/ZSI/TC.py 2006-12-04 18:00:03 UTC (rev 1301) @@ -1789,7 +1789,67 @@ str(C) + ' duplicating serial registration for ' + str(t)) Any.serialmap[key] = instance +def _DynamicImport(moduleName, className): + ''' + Utility function for RegisterTypeWithSchemaAndClass + ''' + mod = __import__(moduleName) + components = moduleName.split('.') + for comp in components[1:]: + mod = getattr(mod, comp) + return getattr(mod, className) +def _RegisterTypeWithSchemaAndClass(importedSchemaTypes, schemaTypeName, classModuleName, className, generatedClassSuffix="_"): + ''' + Used by RegisterGeneratedTypesWithMapping. + Helps register classes so they can be serialized and parsed as "any". + Register a type by providing its schema and class. This allows + Any and AnyType to reconstruct objects made up of your own classes. + Note: The class module should be able to be imported (by being in your + pythonpath). Your classes __init__ functions shoud have default + arguments for all extra parameters. + Example of use: + import SchemaToPyTypeMap # Mapping written by you. Also used with wsdl2py -m + # mapping = {"SomeDescription":("Descriptions", "SomeDescription"), + # schemaTypeName : moduleName , className + # The module on the next line is generated by wsdl2py + from EchoServer_services_types import urn_ZSI_examples as ExampleTypes + + for key,value in SchemaToPyTypeMap.mapping.items(): + ZSI.TC.RegisterTypeWithSchemaAndClass(importedSchemaTypes = ExampleTypes, schemaTypeName=key, classModuleName=value[0], className=value[1]) + + ''' + # Doing this: (schemaTypeName="ExampleTypes", classModuleName="Description", + # className="SomeDescription") + # sd_instance = ExampleTypes.SomeDescription_(pname="SomeDescription") + # Any.serialmap[Descriptions.SomeDescription] = sd_instance + # Any.parsemap[(None,'SomeDescription')] = sd_instance + classDef = _DynamicImport(classModuleName, className) + interfaceDef = getattr(importedSchemaTypes, schemaTypeName + generatedClassSuffix) + + instance = interfaceDef(pname=className) + Any.serialmap[classDef] = instance + Any.parsemap[(None,schemaTypeName)] = instance + +def RegisterGeneratedTypesWithMapping(generatedTypes, mapping, generatedClassSuffix="_"): + """ + Registers python classes so they can be serialized and parsed as "any". + generatedTypes is a class containing typecode classes generated by zsi. + mapping is a dictionary that maps + {schemaTypeName : moduleName, className} + and is also used with wsdl2py -m + + Example of use: + import SchemaToPyTypeMap # See RegisterTypeWithSchemaAndClass for description + # The module on the next line is generated by wsdl2py and + # contains generated typecodes. + from EchoServer_services_types import urn_ZSI_examples as ExampleTypes + RegisterGeneratedTypesWithMapping(generatedTypes = ExampleTypes, mapping=SchemaToPyTypeMap.mapping) + """ + for key,value in mapping.items(): + _RegisterTypeWithSchemaAndClass(importedSchemaTypes = generatedTypes, schemaTypeName=key, classModuleName=value[0], className=value[1], generatedClassSuffix=generatedClassSuffix) + + from TCnumbers import * from TCtimes import * from schema import GTD, GED, WrapImmutable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fea...@us...> - 2006-12-15 02:25:58
|
Revision: 1304 http://svn.sourceforge.net/pywebsvcs/?rev=1304&view=rev Author: feanor420 Date: 2006-12-14 18:22:06 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Fixes Bugs item #1615921 StringIO was used but not imported. Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-12-05 06:43:29 UTC (rev 1303) +++ trunk/zsi/ZSI/TC.py 2006-12-15 02:22:06 UTC (rev 1304) @@ -21,6 +21,10 @@ from base64 import decodestring as b64decode, encodestring as b64encode from urllib import unquote as urldecode, quote as urlencode from binascii import unhexlify as hexdecode, hexlify as hexencode +try: + import cStringIO as StringIO +except ImportError: + import StringIO _is_xsd_or_soap_ns = lambda ns: ns in [ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2006-12-19 00:21:32
|
Revision: 1305 http://svn.sourceforge.net/pywebsvcs/?rev=1305&view=rev Author: boverhof Date: 2006-12-18 16:21:28 -0800 (Mon, 18 Dec 2006) Log Message: ----------- M ZSI/TC.py - applied patch for bug "[ 1616810 ] serializing of a union results in a TypeError" Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-12-15 02:22:06 UTC (rev 1304) +++ trunk/zsi/ZSI/TC.py 2006-12-19 00:21:28 UTC (rev 1305) @@ -1486,7 +1486,7 @@ for nsuri,name in self.__class__.memberTypes: tcclass = GTD(nsuri,name) if tcclass is None: - tc = Any.parsemap.get((nsuri,name)) + tc = Any.parsemap.get((nsuri,name)) or Any.parsemap.get((None, name)) typecode = tc.__class__(pname=(self.nspname,self.pname)) else: typecode = tcclass(pname=(self.nspname,self.pname)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2006-12-19 01:24:10
|
Revision: 1308 http://svn.sourceforge.net/pywebsvcs/?rev=1308&view=rev Author: boverhof Date: 2006-12-18 17:24:09 -0800 (Mon, 18 Dec 2006) Log Message: ----------- M ZSI/TC.py -- need to look for TypeError when parsing using Union Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2006-12-19 01:21:50 UTC (rev 1307) +++ trunk/zsi/ZSI/TC.py 2006-12-19 01:24:09 UTC (rev 1308) @@ -1538,7 +1538,7 @@ try: content = typecode.get_formatted_content(copy.copy(pyobj)) break - except ParseException, ex: + except (ParseException, TypeError): pass if indx > 0: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2007-01-24 21:47:46
|
Revision: 1327 http://svn.sourceforge.net/pywebsvcs/?rev=1327&view=rev Author: boverhof Date: 2007-01-24 13:37:43 -0800 (Wed, 24 Jan 2007) Log Message: ----------- M ZSI/TC.py -- merge changes into trunk Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2007-01-24 21:32:03 UTC (rev 1326) +++ trunk/zsi/ZSI/TC.py 2007-01-24 21:37:43 UTC (rev 1327) @@ -572,8 +572,9 @@ return [ self.__class__(**self.kwargs).parse(e, ps) for e in _child_elements(elt) ] if len(_child_elements(elt)) == 0: - raise EvaluateException("Any cannot parse untyped element", - ps.Backtrace(elt)) + #raise EvaluateException("Any cannot parse untyped element", + # ps.Backtrace(elt)) + return self.simple_value(elt, ps) return self.parse_into_dict_or_list(elt, ps) parser = Any.parsemap.get((ns,type)) if not parser and _is_xsd_or_soap_ns(ns): @@ -1455,14 +1456,18 @@ what = _AnyStrict(pname=(nspname,pname)) try: - pyobj = what.parse(elt, ps) + return what.parse(elt, ps) except EvaluateException, ex: + self.logger.debug("error parsing: %s" %str(ex)) + + if len(_children(elt)) == 0: self.logger.debug("Give up, parse (%s,%s) as a String", what.nspname, what.pname) what = String(pname=(nspname,pname), typed=False) - pyobj = WrapImmutable(what.parse(elt, ps), what) + return WrapImmutable(what.parse(elt, ps), what) - return pyobj + self.logger.debug('parse <any>, return as dict') + return Any(aslist=False).parse_into_dict_or_list(elt, ps) class Union(SimpleType): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fea...@us...> - 2007-03-03 20:33:06
|
Revision: 1362 http://svn.sourceforge.net/pywebsvcs/?rev=1362&view=rev Author: feanor420 Date: 2007-03-03 12:33:05 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Minor fix with the usage of urllib.quote. safe is not a keyword argument. Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2007-02-21 21:14:10 UTC (rev 1361) +++ trunk/zsi/ZSI/TC.py 2007-03-03 20:33:05 UTC (rev 1362) @@ -741,8 +741,9 @@ def get_formatted_content(self, pyobj): '''typecode data --> text ''' + u = urlencode(pyobj, self.reserved) return String.get_formatted_content(self, - urlencode(pyobj, safe=self.reserved)) + u) class QName(String): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2008-02-14 17:45:51
|
Revision: 1446 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1446&view=rev Author: boverhof Date: 2008-02-14 09:45:56 -0800 (Thu, 14 Feb 2008) Log Message: ----------- M ZSI/TC.py small nilled element patch for a few simple types that use SimpleHREF method of Typecode class. Reference From: re...@ho... Subject: RE: [Pywebsvcs-talk] Patch for TC.py Date: February 12, 2008 1:14:55 PM PST To: jrb...@lb... Cc: pyw...@li... Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2008-01-29 15:58:58 UTC (rev 1445) +++ trunk/zsi/ZSI/TC.py 2008-02-14 17:45:56 UTC (rev 1446) @@ -151,7 +151,7 @@ if len(_children(elt)): return elt href = _find_href(elt) if not href: - if self.minOccurs is 0: return None + if self.minOccurs is 0 or self.nilled(elt, ps): return None raise EvaluateException('Required' + tag + ' missing', ps.Backtrace(elt)) return ps.FindLocalHREF(href, elt, 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |