You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(47) |
Apr
(48) |
May
(68) |
Jun
(9) |
Jul
(43) |
Aug
(10) |
Sep
(81) |
Oct
(43) |
Nov
(22) |
Dec
(60) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(44) |
Feb
(48) |
Mar
(53) |
Apr
(40) |
May
(107) |
Jun
(28) |
Jul
(8) |
Aug
(8) |
Sep
(28) |
Oct
(32) |
Nov
(43) |
Dec
(13) |
2005 |
Jan
(45) |
Feb
(110) |
Mar
(36) |
Apr
(14) |
May
(28) |
Jun
(3) |
Jul
(10) |
Aug
(8) |
Sep
(27) |
Oct
(13) |
Nov
(3) |
Dec
(20) |
2006 |
Jan
(32) |
Feb
(29) |
Mar
(17) |
Apr
(21) |
May
(38) |
Jun
(14) |
Jul
(6) |
Aug
(2) |
Sep
(4) |
Oct
(36) |
Nov
(11) |
Dec
(10) |
2007 |
Jan
(41) |
Feb
(10) |
Mar
(7) |
Apr
(7) |
May
(10) |
Jun
(15) |
Jul
(11) |
Aug
(1) |
Sep
(3) |
Oct
(13) |
Nov
(16) |
Dec
(1) |
2008 |
Jan
(9) |
Feb
(1) |
Mar
|
Apr
|
May
(22) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(7) |
2009 |
Jan
(3) |
Feb
(1) |
Mar
(3) |
Apr
(6) |
May
(3) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <bov...@us...> - 2014-01-20 19:37:12
|
Revision: 1503 http://sourceforge.net/p/pywebsvcs/code/1503 Author: boverhof Date: 2014-01-20 19:37:08 +0000 (Mon, 20 Jan 2014) Log Message: ----------- _M ZSI -- update externals Property Changed: ---------------- trunk/zsi/ZSI/ Index: trunk/zsi/ZSI =================================================================== --- trunk/zsi/ZSI 2012-03-29 10:46:23 UTC (rev 1502) +++ trunk/zsi/ZSI 2014-01-20 19:37:08 UTC (rev 1503) Property changes on: trunk/zsi/ZSI ___________________________________________________________________ Modified: svn:externals ## -1 +1 ## -wstools https://pywebsvcs.svn.sourceforge.net/svnroot/pywebsvcs/trunk/wstools +wstools https://svn.code.sf.net/p/pywebsvcs/code/trunk/wstools This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <em...@us...> - 2012-03-29 10:46:33
|
Revision: 1502 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1502&view=rev Author: emmebi Date: 2012-03-29 10:46:23 +0000 (Thu, 29 Mar 2012) Log Message: ----------- Just a little clean-up of the existing tests, plus the removal of a few warnings. Modified Paths: -------------- trunk/zsi/ZSI/digest_auth.py trunk/zsi/ZSI/resolvers.py trunk/zsi/test/test_AnyType.py trunk/zsi/test/test_QName.py trunk/zsi/test/test_TCtimes.py trunk/zsi/test/test_URI.py trunk/zsi/test/test_callhome.py trunk/zsi/test/test_list.py trunk/zsi/test/test_rfc2617.py trunk/zsi/test/test_t1.py trunk/zsi/test/test_t2.py trunk/zsi/test/test_t3.py trunk/zsi/test/test_t4.py trunk/zsi/test/test_t5.py trunk/zsi/test/test_t6.py trunk/zsi/test/test_t7.py trunk/zsi/test/test_t9.py trunk/zsi/test/test_union.py trunk/zsi/test/test_zsi.py trunk/zsi/test/test_zsi_net.py Modified: trunk/zsi/ZSI/digest_auth.py =================================================================== --- trunk/zsi/ZSI/digest_auth.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/ZSI/digest_auth.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -2,11 +2,14 @@ # $Header$ '''Utilities for HTTP Digest Authentication ''' +import httplib +import random import re -from md5 import md5 -import random import time -import httplib +try: + from hashlib import md5 +except ImportError: + from md5 import md5 random.seed(int(time.time()*10)) Modified: trunk/zsi/ZSI/resolvers.py =================================================================== --- trunk/zsi/ZSI/resolvers.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/ZSI/resolvers.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -3,12 +3,18 @@ '''SOAP messaging parsing. ''' -from ZSI import _copyright, _child_elements, EvaluateException, TC -import multifile, mimetools, urllib +try: + import cStringIO as StringIO +except ImportError: + import StringIO +import multifile +import mimetools +import urllib from base64 import decodestring as b64decode -import cStringIO as StringIO +from ZSI import _copyright, _child_elements, EvaluateException, TC + def Opaque(uri, tc, ps, **keywords): '''Resolve a URI and return its content as a string. ''' Modified: trunk/zsi/test/test_AnyType.py =================================================================== --- trunk/zsi/test/test_AnyType.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_AnyType.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,11 +1,9 @@ #!/usr/bin/env python -import unittest, sys, tests_good, tests_bad, time -from ZSI import * -try: - import cStringIO as StringIO -except ImportError: - import StringIO +import unittest + +from ZSI import schema, ParsedSoap, TC + """Bug [ 1520092 ] URI Bug: urllib.quote escaping reserved chars Bug [ 2748314 ] Malformed type attribute (bad NS) with 2.1a1 but not with 2. """ Modified: trunk/zsi/test/test_QName.py =================================================================== --- trunk/zsi/test/test_QName.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_QName.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,12 +1,9 @@ #!/usr/bin/env python -import unittest, sys, tests_good, tests_bad, time -from ZSI import * -try: - import cStringIO as StringIO -except ImportError: - import StringIO +import unittest +from ZSI import ParsedSoap, TC, FaultFromFaultMessage + """Bug [ 1520092 ] URI Bug: urllib.quote escaping reserved chars Bug [ 2748314 ] Malformed type attribute (bad NS) with 2.1a1 but not with 2. """ @@ -33,7 +30,6 @@ </soapenv:Body> </soapenv:Envelope>""" - from ZSI import ParsedSoap, FaultFromFaultMessage ps = ParsedSoap(msg) fault = FaultFromFaultMessage(ps) self.failUnless(fault.code == ('','ServerFaultCode'), 'faultcode should be (namespace,name) tuple') Modified: trunk/zsi/test/test_TCtimes.py =================================================================== --- trunk/zsi/test/test_TCtimes.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_TCtimes.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,8 +1,11 @@ #!/usr/bin/env python # vim: sts=4 sw=4 et -import unittest, sys, tests_good, tests_bad, time, os -from ZSI import * +import os +import time +import unittest + +from ZSI import TC try: import cStringIO as StringIO except ImportError: Modified: trunk/zsi/test/test_URI.py =================================================================== --- trunk/zsi/test/test_URI.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_URI.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,12 +1,9 @@ #!/usr/bin/env python -import unittest, sys, tests_good, tests_bad, time -from ZSI import * -try: - import cStringIO as StringIO -except ImportError: - import StringIO +import unittest +from ZSI import ParsedSoap, SoapWriter, TC + """Bug [ 1520092 ] URI Bug: urllib.quote escaping reserved chars From rfc2396: @@ -45,8 +42,8 @@ sw2.serialize(orig, typecode=tc2, typed=False) s2 = str(sw2) - print s1 - print s2 +# print s1 +# print s2 self.failUnless(s1 == s2, 'reserved characters used for reserved purpose should not be escaped.') Modified: trunk/zsi/test/test_callhome.py =================================================================== --- trunk/zsi/test/test_callhome.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_callhome.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,5 +1,8 @@ #!/usr/bin/env python -import os,unittest + +import os +import unittest + from ZSI import version from ZSI.wstools.logging import gridLog @@ -9,7 +12,8 @@ class TestCase(unittest.TestCase): def ping(self): - gridLog(event="zsi.test.test_callhome.ping", zsi="v%d.%d.%d" % version.Version, prog="test_callhome.py") + gridLog(event="zsi.test.test_callhome.ping", zsi="v%d.%d.%d" % version.Version, + prog="test_callhome.py") def makeTestSuite(): suite = unittest.TestSuite() Modified: trunk/zsi/test/test_list.py =================================================================== --- trunk/zsi/test/test_list.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_list.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,13 +1,15 @@ #!/usr/bin/env python -import unittest, time, datetime + +import time +import unittest +from cStringIO import StringIO + import ZSI from ZSI.writer import SoapWriter from ZSI import _get_element_nsuri_name from ZSI.schema import GED, TypeDefinition, ElementDeclaration from ZSI.parse import ParsedSoap -from cStringIO import StringIO - class TestList1_Def(ZSI.TC.List, TypeDefinition): itemType = (u'http://www.w3.org/2001/XMLSchema', u'dateTime') schema = "urn:test" @@ -15,7 +17,6 @@ def __init__(self, pname, **kw): ZSI.TC.List.__init__(self, pname, **kw) - class TestList2_Def(ZSI.TC.List, TypeDefinition): itemType = ZSI.TC.gDateTime() schema = "urn:test" @@ -23,7 +24,6 @@ def __init__(self, pname, **kw): ZSI.TC.List.__init__(self, pname, **kw) - class ListTestCase(unittest.TestCase): "test List TypeCode" @@ -44,7 +44,7 @@ sw = SoapWriter() sw.serialize(data, typecode) s = str(sw) - print s + #print s ps = ParsedSoap(s); pyobj = ps.Parse(typecode) assert pyobj == data, 'Data corruption expected "%s", got "%s"' %(str(data),str(pyobj)) if data is None: @@ -57,7 +57,6 @@ utc = list(time.gmtime(i)[:-3]) + [999,0,0] data.append(tuple(utc)) - def makeTestSuite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ListTestCase, "check")) Modified: trunk/zsi/test/test_rfc2617.py =================================================================== --- trunk/zsi/test/test_rfc2617.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_rfc2617.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -4,19 +4,19 @@ HTTP Authentication: Basic and Digest Access Authentication """ + import unittest + from ZSI import digest_auth -from ZSI.wstools.logging import setBasicLoggerDEBUG -setBasicLoggerDEBUG() class DATestCase(unittest.TestCase): "test Union TypeCode" def check_challenge_single_www_authenticate_header(self): challenge='Basic realm="WallyWorld"' - print "=="*30 - print challenge - print "=="*30 + #print "=="*30 + #print challenge + #print "=="*30 cd = digest_auth.fetch_challenge(challenge) expect = {'challenge': 'Basic', 'realm': 'WallyWorld'} self.failUnless(cd == expect, 'Expected equivalent') Modified: trunk/zsi/test/test_t1.py =================================================================== --- trunk/zsi/test/test_t1.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t1.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,11 +1,18 @@ #!/usr/bin/env python -import unittest, sys, tests_good, tests_bad, time -from ZSI import * try: import cStringIO as StringIO except ImportError: import StringIO +import unittest +import sys +import time +from ZSI import * + +import tests_good +import tests_bad + + class t1TestCase(unittest.TestCase): "Test case wrapper for old ZSI t1 test case" @@ -35,10 +42,10 @@ def checkt1(self): for key,val in self.badTests: - print "\n", "." * 60, key + #print "\n", "." * 60, key self.failUnlessRaises(ParseException, ParsedSoap, val) for key,val in self.goodTests: - print "\n", "." * 60, key + #print "\n", "." * 60, key ps = ParsedSoap(val) ps = ParsedSoap(datatest) @@ -141,13 +148,13 @@ a = bar() except Exception, e: f = FaultFromException(e, 0, sys.exc_info()[2]) - print f.AsSOAP() - print - print - print FaultFromNotUnderstood('myuri', 'dalocalname', actor='cher').AsSOAP() - print - print - print FaultFromActor('actor:i:dont:understand').AsSOAP() + #print f.AsSOAP() + #print + #print + #print FaultFromNotUnderstood('myuri', 'dalocalname', actor='cher').AsSOAP() + #print + #print + #print FaultFromActor('actor:i:dont:understand').AsSOAP() def makeTestSuite(): @@ -163,12 +170,15 @@ def bar(): return foo() + 2 -class zParseException: pass +class zParseException: + pass class myclass: + def __init__(self, name=None): self.name = name or id(self) self.z = 'z value' + def __str__(self): return 'myclass-%s-(%d,"%s")' % (self.name, self.i, self.t) + \ str(self.z) @@ -229,7 +239,7 @@ def main(): unittest.main(defaultTest="makeTestSuite") +if __name__ == "__main__" : + main() -if __name__ == "__main__" : main() - Modified: trunk/zsi/test/test_t2.py =================================================================== --- trunk/zsi/test/test_t2.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t2.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,8 +1,11 @@ #!/usr/bin/env python -import unittest, sys -from ZSI import * +import sys +import unittest +from ZSI import TC, ParsedSoap, ParseException, FaultFromZSIException, FaultFromException, SoapWriter + + class t2TestCase(unittest.TestCase): "Test case wrapper for old ZSI t2 test case" @@ -40,8 +43,9 @@ import operator total = reduce(operator.add, player.Scores, 0) result = Average(foo(total, len(player.Scores))) - sw = SoapWriter().serialize(result) - print >>OUT, str(sw) + sw = SoapWriter().serialize(result) + str(sw) + #print >>OUT, str(sw) except Exception, e: print >>OUT, FaultFromException(e, 0, sys.exc_info()[2]).AsSOAP() self.fail() Modified: trunk/zsi/test/test_t3.py =================================================================== --- trunk/zsi/test/test_t3.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t3.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,8 +1,8 @@ #!/usr/bin/env python import unittest from ZSI import * -from ZSI.wstools.logging import setBasicLoggerDEBUG -setBasicLoggerDEBUG() +#from ZSI.wstools.logging import setBasicLoggerDEBUG +#setBasicLoggerDEBUG() class t3TestCase(unittest.TestCase): "Test case wrapper for old ZSI t3 test case" @@ -17,14 +17,14 @@ text = f.AsSOAP() i = 0 for l in text.split('\n'): - print i, l + #print i, l i += 1 ps = ParsedSoap(text) if ps.IsAFault(): f = FaultFromFaultMessage(ps) - print f.AsSOAP() + #print f.AsSOAP() self.failUnless(f.AsSOAP().find(str(a)) > 0) - print '--'*20 + #print '--'*20 def makeTestSuite(): Modified: trunk/zsi/test/test_t4.py =================================================================== --- trunk/zsi/test/test_t4.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t4.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -32,7 +32,7 @@ # Faulted while processing; assume it's in the header. print >>OUT, FaultFromException(e, 1, sys.exc_info()[2]).AsSOAP() self.fail() - print 'resolving' + #print 'resolving' typecode = TC.Struct(None, [ TC.XML('xmltest'), TC.String('stringtest', resolver=r.Opaque), ]) try: @@ -45,7 +45,7 @@ print >>OUT, FaultFromException(e, 0, sys.exc_info()[2]).AsSOAP() self.fail() ##PrettyPrint(dict['xmltest']) - print '**', dict['stringtest'], '**' + #print '**', dict['stringtest'], '**' def makeTestSuite(): suite = unittest.TestSuite() Modified: trunk/zsi/test/test_t5.py =================================================================== --- trunk/zsi/test/test_t5.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t5.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,17 +1,16 @@ #!/usr/bin/env python -import unittest, multifile, mimetools -from ZSI import * -from ZSI import resolvers -from xml.dom import Node -#from xml.dom.ext.reader import PyExpat -from ZSI.parse import DefaultReader as Reader - +import mimetools +import unittest try: import cStringIO as StringIO except ImportError: import StringIO +from ZSI import resolvers +from ZSI.parse import DefaultReader as Reader + + class t5TestCase(unittest.TestCase): "Test case wrapper for old ZSI t5 test case" @@ -21,11 +20,11 @@ if m.gettype()[0:10] == "multipart/": cid = resolvers.MIMEResolver(m['content-type'], istr) xml = cid.GetSOAPPart() - print 'xml=', xml.getvalue() - for h,b in cid.parts: - print h, b.read() + #print 'xml=', xml.getvalue() +# for h,b in cid.parts: +# print h, b.read() dom = Reader.fromStream(xml) - print dom + #print dom def makeTestSuite(): suite = unittest.TestSuite() Modified: trunk/zsi/test/test_t6.py =================================================================== --- trunk/zsi/test/test_t6.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t6.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,6 +1,11 @@ #!/usr/bin/env python -import unittest, sys, multifile, mimetools, base64 -from ZSI import * +import unittest +import sys +import multifile +import mimetools +import base64 + +from ZSI import TC, ParseException, FaultFromException, ParsedSoap from ZSI import resolvers try: import cStringIO as StringIO @@ -34,16 +39,16 @@ self.failUnlessEqual(dict['stringtest'], strExtTest, "Failed to extract stringtest correctly") - print base64.encodestring(cid['pa...@zo...'].read()) + #print base64.encodestring(cid['pa...@zo...'].read()) v = dict['b64'] - print type(v), 'is type(v)' + #print type(v), 'is type(v)' self.failUnlessEqual(cid['pa...@zo...'].getvalue(), v, "mismatch") - print base64.encodestring(v) - from ZSI.wstools.c14n import Canonicalize - z = dict['xmltest'] - print type(z), z - print Canonicalize(z) + #print base64.encodestring(v) + #from ZSI.wstools.c14n import Canonicalize + #z = dict['xmltest'] + #print type(z), z + #print Canonicalize(z) def makeTestSuite(): suite = unittest.TestSuite() Modified: trunk/zsi/test/test_t7.py =================================================================== --- trunk/zsi/test/test_t7.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t7.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,8 +1,10 @@ #!/usr/bin/env python -import unittest, sys -from ZSI import * +import unittest +import sys +from ZSI import ParsedSoap, SoapWriter, TC + class t7TestCase(unittest.TestCase): "Test case wrapper for old ZSI t7 test case" @@ -14,22 +16,22 @@ d = tcdict.parse(ps.body_root, ps) self.assertEqual(d, { u'a':123, '\x00\x01':456 }) - print 'as dictionary\n', d + #print 'as dictionary\n', d l = tclist.parse(ps.body_root, ps) self.assertEqual(l, [('\x00\x01', 456), (u'a', 123)]) - print '\n', '=' * 30 - print 'as list\n', l + #print '\n', '=' * 30 + #print 'as list\n', l - print '\n', '=' * 30 + #print '\n', '=' * 30 sw = SoapWriter() sw.serialize(d, tcdict) - print >>sys.stdout, sw + #print >>sys.stdout, sw - print '\n', '=' * 30 + #print '\n', '=' * 30 sw = SoapWriter() sw.serialize(l, tclist) - print >>sys.stdout, sw + #print >>sys.stdout, sw def makeTestSuite(): suite = unittest.TestSuite() Modified: trunk/zsi/test/test_t9.py =================================================================== --- trunk/zsi/test/test_t9.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_t9.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,5 +1,13 @@ #!/usr/bin/env python -import unittest, sys, sha, base64 + +import base64 +import unittest +try: + from hashlib import sha1 as local_sha +except ImportError: + import sha1 as local_sha +import sys + from ZSI import _get_element_nsuri_name from ZSI.parse import ParsedSoap from ZSI.wstools.c14n import Canonicalize @@ -25,8 +33,8 @@ s = StringIO() Canonicalize(self.el, s, unsuppressedPrefixes=None) cxml = s.getvalue() - d1 = base64.encodestring(sha.sha(C14N_INC1).digest()).strip() - d2 = base64.encodestring(sha.sha(cxml).digest()).strip() + d1 = base64.encodestring(local_sha(C14N_INC1).digest()).strip() + d2 = base64.encodestring(local_sha(cxml).digest()).strip() self.assertEqual(d1, d2) self.assertEqual(d1, C14N_INC1_DIGEST) @@ -36,8 +44,8 @@ s = StringIO() Canonicalize(self.el, s, unsuppressedPrefixes=[]) cxml = s.getvalue() - d1 = base64.encodestring(sha.sha(C14N_EXCL1).digest()).strip() - d2 = base64.encodestring(sha.sha(cxml).digest()).strip() + d1 = base64.encodestring(local_sha(C14N_EXCL1).digest()).strip() + d2 = base64.encodestring(local_sha(cxml).digest()).strip() self.assertEqual(d1, C14N_EXCL1_DIGEST) self.assertEqual(d1, d2) @@ -50,8 +58,8 @@ s = StringIO() Canonicalize(self.el, s, unsuppressedPrefixes=['xsi', 'xsd']) cxml = s.getvalue() - d1 = base64.encodestring(sha.sha(C14N_EXCL2).digest()).strip() - d2 = base64.encodestring(sha.sha(cxml).digest()).strip() + d1 = base64.encodestring(local_sha(C14N_EXCL2).digest()).strip() + d2 = base64.encodestring(local_sha(cxml).digest()).strip() self.assertEqual(d1, C14N_EXCL2_DIGEST) self.assertEqual(d1, d2) @@ -67,9 +75,9 @@ s = StringIO() Canonicalize(self.el, s, unsuppressedPrefixes=[]) cxml = s.getvalue() - print cxml - d1 = base64.encodestring(sha.sha(C14N_EXCL3).digest()).strip() - d2 = base64.encodestring(sha.sha(cxml).digest()).strip() + #print cxml + d1 = base64.encodestring(local_sha(C14N_EXCL3).digest()).strip() + d2 = base64.encodestring(local_sha(cxml).digest()).strip() self.assertEqual(d1, C14N_EXCL3_DIGEST) self.assertEqual(d1, d2) @@ -77,8 +85,8 @@ RCVDIGEST = "jhTbi7gWlY9oLqsRr+EZ0bokRFA=" CALDIGEST = "IkMyI4zCDlK41qE7sZxvkFHJioU=" - d1 = base64.encodestring(sha.sha(WRONG).digest()).strip() - d2 = base64.encodestring(sha.sha(CORRECT).digest()).strip() + d1 = base64.encodestring(local_sha(WRONG).digest()).strip() + d2 = base64.encodestring(local_sha(CORRECT).digest()).strip() ps = ParsedSoap(XML_INST4) el = filter(lambda el: _get_element_nsuri_name(el) == (WSA200403.ADDRESS, "MessageID"), @@ -87,10 +95,10 @@ s = StringIO() Canonicalize(el, s, unsuppressedPrefixes=[]) cxml = s.getvalue() - print "-- "*20 - print cxml - print "-- "*20 - d3 = base64.encodestring(sha.sha(cxml).digest()).strip() +# print "-- "*20 +# print cxml +# print "-- "*20 + d3 = base64.encodestring(local_sha(cxml).digest()).strip() self.assertEqual(d1, RCVDIGEST) self.assertEqual(d2, CALDIGEST) Modified: trunk/zsi/test/test_union.py =================================================================== --- trunk/zsi/test/test_union.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_union.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -1,12 +1,15 @@ #!/usr/bin/env python -import unittest, sys, sha, base64 +import base64 +import unittest +import sys +from cStringIO import StringIO + import ZSI from ZSI import _get_element_nsuri_name from ZSI.schema import GED, TypeDefinition, ElementDeclaration from ZSI.parse import ParsedSoap from ZSI.wstools.c14n import Canonicalize from ZSI.wstools.Namespaces import WSA200403, SOAP -from cStringIO import StringIO # # Generated code Modified: trunk/zsi/test/test_zsi.py =================================================================== --- trunk/zsi/test/test_zsi.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_zsi.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -26,4 +26,5 @@ unittest.main(defaultTest="makeTestSuite") suite = unittest.TestSuite() -if __name__ == "__main__" : main() +if __name__ == "__main__": + main() Modified: trunk/zsi/test/test_zsi_net.py =================================================================== --- trunk/zsi/test/test_zsi_net.py 2011-12-01 08:17:02 UTC (rev 1501) +++ trunk/zsi/test/test_zsi_net.py 2012-03-29 10:46:23 UTC (rev 1502) @@ -13,4 +13,5 @@ unittest.main(defaultTest="makeTestSuite") suite = unittest.TestSuite() -if __name__ == "__main__" : main() +if __name__ == "__main__" : + main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <em...@us...> - 2011-12-01 08:17:13
|
Revision: 1501 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1501&view=rev Author: emmebi Date: 2011-12-01 08:17:02 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Just a quick fix: the zsi.xsd was not available anymore at the old location, so I moved it into the ZSI website, which should provide a more stable URL. Modified Paths: -------------- trunk/zsi/setup.cfg trunk/zsi/test/test_t4.py Modified: trunk/zsi/setup.cfg =================================================================== --- trunk/zsi/setup.cfg 2011-11-21 17:58:29 UTC (rev 1500) +++ trunk/zsi/setup.cfg 2011-12-01 08:17:02 UTC (rev 1501) @@ -8,7 +8,7 @@ minor = 1 patchlevel = 0 candidate = 0 -alpha = 1 +alpha = 2 beta = 0 [egg_info] Modified: trunk/zsi/test/test_t4.py =================================================================== --- trunk/zsi/test/test_t4.py 2011-11-21 17:58:29 UTC (rev 1500) +++ trunk/zsi/test/test_t4.py 2011-12-01 08:17:02 UTC (rev 1501) @@ -11,7 +11,7 @@ xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"> <SOAP-ENV:Body> <hreftest> - <xmltest href="http://www-itg.lbl.gov/~kjackson/zsi.xsd"/> + <xmltest href="http://pywebsvcs.sourceforge.net/zsi.xsd"/> <stringtest href="http://www.microsoft.com"/> </hreftest> </SOAP-ENV:Body> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2011-11-21 17:58:40
|
Revision: 1500 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1500&view=rev Author: boverhof Date: 2011-11-21 17:58:29 +0000 (Mon, 21 Nov 2011) Log Message: ----------- M XMLSchema.py -- forget to commit Modified Paths: -------------- trunk/wstools/XMLSchema.py Modified: trunk/wstools/XMLSchema.py =================================================================== --- trunk/wstools/XMLSchema.py 2011-11-18 00:37:13 UTC (rev 1499) +++ trunk/wstools/XMLSchema.py 2011-11-21 17:58:29 UTC (rev 1500) @@ -1211,6 +1211,7 @@ slocd[import_ns] = schema try: tp.loadSchema(schema) + """ except NoSchemaLocationWarning, ex: # Dependency declaration, hopefully implementation # is aware of this namespace (eg. SOAP,WSDL,?) @@ -1219,6 +1220,8 @@ del slocd[import_ns] continue except SchemaError, ex: + """ + except (NoSchemaLocationWarning,SchemaError), ex: #warnings.warn(\ # '<import namespace="%s" schemaLocation=?>, %s'\ # %(import_ns, 'failed to load schema instance') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2011-11-18 00:37:19
|
Revision: 1499 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1499&view=rev Author: boverhof Date: 2011-11-18 00:37:13 +0000 (Fri, 18 Nov 2011) Log Message: ----------- M ZSI/generate/commands.py M ZSI/generate/containers.py -- fixed a logic error with a loop that figures out minOccurs, it never stopped when it failed to find a specified minOccurs because it didn't exit when the parent wasn't sequence or something. -- set wsdl2py to spew out logger.warning by default -- simpleType restriction's of a user defined base rather than quiting just use xsd:string as the base. Modified Paths: -------------- trunk/zsi/ZSI/generate/commands.py trunk/zsi/ZSI/generate/containers.py Modified: trunk/zsi/ZSI/generate/commands.py =================================================================== --- trunk/zsi/ZSI/generate/commands.py 2010-03-12 02:13:19 UTC (rev 1498) +++ trunk/zsi/ZSI/generate/commands.py 2011-11-18 00:37:13 UTC (rev 1499) @@ -12,7 +12,7 @@ from ConfigParser import ConfigParser from ZSI.generate.wsdl2python import WriteServiceModule, ServiceDescription as wsdl2pyServiceDescription from ZSI.wstools import WSDLTools, XMLSchema -from ZSI.wstools.logging import setBasicLoggerDEBUG +from ZSI.wstools.logging import setBasicLoggerDEBUG,setBasicLoggerWARN from ZSI.generate import containers, utility from ZSI.generate.utility import NCName_to_ClassName as NC_to_CN, TextProtect from ZSI.generate.wsdl2dispatch import ServiceModuleWriter as ServiceDescription @@ -110,7 +110,7 @@ action="store_true", dest="pydoc", default=False, help="top-level directory for pydoc documentation.") - + setBasicLoggerWARN() is_cmdline = args is None if is_cmdline: (options, args) = op.parse_args() Modified: trunk/zsi/ZSI/generate/containers.py =================================================================== --- trunk/zsi/ZSI/generate/containers.py 2010-03-12 02:13:19 UTC (rev 1498) +++ trunk/zsi/ZSI/generate/containers.py 2011-11-18 00:37:13 UTC (rev 1499) @@ -1565,8 +1565,9 @@ # because cannot follow references, but not currently # a big concern. - self.logger.debug("flat: %r" %list(flat)) + #self.logger.debug("flat: %r" %list(flat)) for c in flat: + self.logger.debug("flat: %r" %c) tc = TcListComponentContainer() # TODO: Remove _getOccurs min,max,nil = self._getOccurs(c) @@ -1609,9 +1610,13 @@ if parent.isReference(): parent = parent.getModelGroupReference() - + continue + if parent.isDefinition(): parent = parent.content + continue + + break tc.setOccurs(minOccurs, maxOccurs, nil) processContents = self._getProcessContents(c) @@ -2804,9 +2809,14 @@ raise Wsdl2PythonError('no built-in type nor schema instance type for base attribute("%s","%s"): %s' %( base.getTargetNamespace(), base.getName(), tp.getItemTrace())) - raise Wsdl2PythonError, \ - 'Not Supporting simpleType/Restriction w/User-Defined Base: %s %s' %(tp.getItemTrace(),item.getItemTrace()) + warnings.warn('Using string for simpleType/Restriction w/User-Defined Base: %s %s' %(tp.getItemTrace(),item.getItemTrace())) + self.logger.warning("Unsupported: SimpleType (%s,%s), setting restriction base to xsd:string" %(self.ns, self.name)) + #self.sKlass = "%s.%s" %(base.getName(), base.getTargetNamespace()) + self.sKlass = BTI.get_typeclass("string", SCHEMA.XSD3) + + return + sc = tp.content.getSimpleTypeContent() if sc is not None and True is sc.isSimple() is sc.isLocal() is sc.isDefinition(): base = None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <poo...@us...> - 2010-03-12 02:13:25
|
Revision: 1498 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1498&view=rev Author: pooryorick Date: 2010-03-12 02:13:19 +0000 (Fri, 12 Mar 2010) Log Message: ----------- removed "iter" test as a dump_dispatch criteria, and replaced with explicit "tuple" test Modified Paths: -------------- trunk/SOAPpy/SOAPpy/SOAPBuilder.py Modified: trunk/SOAPpy/SOAPpy/SOAPBuilder.py =================================================================== --- trunk/SOAPpy/SOAPpy/SOAPBuilder.py 2010-03-08 06:06:52 UTC (rev 1497) +++ trunk/SOAPpy/SOAPpy/SOAPBuilder.py 2010-03-12 02:13:19 UTC (rev 1498) @@ -497,6 +497,17 @@ dump_tuple = dump_list + def dump_exception(self, obj, tag, typed = 0, ns_map = {}): + if isinstance(obj, faultType): # Fault + cns, cdecl = self.genns(ns_map, NS.ENC) + vns, vdecl = self.genns(ns_map, NS.ENV) + self.out.append('<%sFault %sroot="1"%s%s>' % (vns, cns, vdecl, cdecl)) + self.dump(obj.faultcode, "faultcode", typed, ns_map) + self.dump(obj.faultstring, "faultstring", typed, ns_map) + if hasattr(obj, "detail"): + self.dump(obj.detail, "detail", typed, ns_map) + self.out.append("</%sFault>\n" % vns) + def dump_dictionary(self, obj, tag, typed = 1, ns_map = {}): if Config.debug: print "In dump_dictionary." tag = tag or self.gentag() @@ -521,14 +532,24 @@ dump_dict = dump_dictionary # For Python 2.2+ def dump_dispatch(self, obj, tag, typed = 1, ns_map = {}): + if not tag: + # If it has a name use it. + if isinstance(obj, anyType) and obj._name: + tag = obj._name + else: + tag = self.gentag() + # watch out for order! dumpmap = ( + (Exception, self.dump_exception), + (arrayType, self.dump_list), (basestring, self.dump_string), (NoneType, self.dump_None), (bool, self.dump_bool), (int, self.dump_int), (long, self.dump_int), (list, self.dump_list), + (tuple, self.dump_list), (dict, self.dump_dictionary), (float, self.dump_float), ) @@ -537,36 +558,6 @@ func(obj, tag, typed, ns_map) return - try: - iter(obj) - except TypeError: - pass - else: - self.dump_list(obj, tag, typed, ns_map) - return - - - if not tag: - # If it has a name use it. - if isinstance(obj, anyType) and obj._name: - tag = obj._name - else: - tag = self.gentag() - - if isinstance(obj, arrayType): # Array - self.dump_list(obj, tag, typed, ns_map) - return - elif isinstance(obj, faultType): # Fault - cns, cdecl = self.genns(ns_map, NS.ENC) - vns, vdecl = self.genns(ns_map, NS.ENV) - self.out.append('<%sFault %sroot="1"%s%s>' % (vns, cns, vdecl, cdecl)) - self.dump(obj.faultcode, "faultcode", typed, ns_map) - self.dump(obj.faultstring, "faultstring", typed, ns_map) - if hasattr(obj, "detail"): - self.dump(obj.detail, "detail", typed, ns_map) - self.out.append("</%sFault>\n" % vns) - return - r = self.genroot(ns_map) try: a = obj._marshalAttrs(ns_map, self) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <poo...@us...> - 2010-03-08 06:07:05
|
Revision: 1497 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1497&view=rev Author: pooryorick Date: 2010-03-08 06:06:52 +0000 (Mon, 08 Mar 2010) Log Message: ----------- overhaul dump operations (dump_instance was never called under newer Python) Modified Paths: -------------- trunk/SOAPpy/SOAPpy/Parser.py trunk/SOAPpy/SOAPpy/SOAPBuilder.py Modified: trunk/SOAPpy/SOAPpy/Parser.py =================================================================== --- trunk/SOAPpy/SOAPpy/Parser.py 2010-03-04 23:46:17 UTC (rev 1496) +++ trunk/SOAPpy/SOAPpy/Parser.py 2010-03-08 06:06:52 UTC (rev 1497) @@ -820,9 +820,6 @@ zerofloatre = '[1-9]' - - - def convertType(self, d, t, attrs, config=Config): if t[0] is None and t[1] is not None: type = t[1].strip() Modified: trunk/SOAPpy/SOAPpy/SOAPBuilder.py =================================================================== --- trunk/SOAPpy/SOAPpy/SOAPBuilder.py 2010-03-04 23:46:17 UTC (rev 1496) +++ trunk/SOAPpy/SOAPpy/SOAPBuilder.py 2010-03-08 06:06:52 UTC (rev 1497) @@ -284,22 +284,7 @@ if type(tag) not in (NoneType, StringType, UnicodeType): raise KeyError, "tag must be a string or None" - try: - meth = getattr(self, "dump_" + type(obj).__name__) - except AttributeError: - if type(obj) == LongType: - obj_type = "integer" - elif pythonHasBooleanType and type(obj) == BooleanType: - obj_type = "boolean" - else: - obj_type = type(obj).__name__ - - self.out.append(self.dumper(None, obj_type, obj, tag, typed, - ns_map, self.genroot(ns_map))) - else: - meth(obj, tag, typed, ns_map) - - + self.dump_dispatch(obj, tag, typed, ns_map) self.depth -= 1 # generic dumper @@ -332,6 +317,7 @@ data = obj + return xml % {"tag": tag, "type": t, "data": data, "root": rootattr, "id": id, "attrs": a} @@ -353,10 +339,20 @@ else: obj = repr(obj) - # Note: python 'float' is actually a SOAP 'double'. - self.out.append(self.dumper(None, "double", obj, tag, typed, ns_map, - self.genroot(ns_map))) + # Note: python 'float' is actually a SOAP 'double'. + self.out.append(self.dumper( + None, "double", obj, tag, typed, ns_map, self.genroot(ns_map))) + def dump_int(self, obj, tag, typed = 1, ns_map = {}): + if Config.debug: print "In dump_int." + self.out.append(self.dumper(None, 'integer', obj, tag, typed, + ns_map, self.genroot(ns_map))) + + def dump_bool(self, obj, tag, typed = 1, ns_map = {}): + if Config.debug: print "In dump_bool." + self.out.append(self.dumper(None, 'boolean', obj, tag, typed, + ns_map, self.genroot(ns_map))) + def dump_string(self, obj, tag, typed = 0, ns_map = {}): if Config.debug: print "In dump_string." tag = tag or self.gentag() @@ -407,12 +403,12 @@ except: # preserve type if present if getattr(obj,"_typed",None) and getattr(obj,"_type",None): - if getattr(obj, "_complexType", None): + if getattr(obj, "_complexType", None): sample = typedArrayType(typed=obj._type, complexType = obj._complexType) sample._typename = obj._type if not getattr(obj,"_ns",None): obj._ns = NS.URN - else: + else: sample = typedArrayType(typed=obj._type) else: sample = structType() @@ -459,7 +455,7 @@ else: t = 'ur-type' else: - typename = type(sample).__name__ + typename = type(sample).__name__ # For Python 2.2+ if type(sample) == StringType: typename = 'string' @@ -467,10 +463,10 @@ # HACK: unicode is a SOAP string if type(sample) == UnicodeType: typename = 'string' - # HACK: python 'float' is actually a SOAP 'double'. - if typename=="float": typename="double" - t = self.genns(ns_map, self.config.typesNamespaceURI)[0] + \ - typename + # HACK: python 'float' is actually a SOAP 'double'. + if typename=="float": typename="double" + t = self.genns( + ns_map, self.config.typesNamespaceURI)[0] + typename else: t = self.genns(ns_map, self.config.typesNamespaceURI)[0] + \ @@ -524,21 +520,43 @@ dump_dict = dump_dictionary # For Python 2.2+ - def dump_instance(self, obj, tag, typed = 1, ns_map = {}): - if Config.debug: print "In dump_instance.", "obj=", obj, "tag=", tag + def dump_dispatch(self, obj, tag, typed = 1, ns_map = {}): + # watch out for order! + dumpmap = ( + (basestring, self.dump_string), + (NoneType, self.dump_None), + (bool, self.dump_bool), + (int, self.dump_int), + (long, self.dump_int), + (list, self.dump_list), + (dict, self.dump_dictionary), + (float, self.dump_float), + ) + for dtype, func in dumpmap: + if isinstance(obj, dtype): + func(obj, tag, typed, ns_map) + return + + try: + iter(obj) + except TypeError: + pass + else: + self.dump_list(obj, tag, typed, ns_map) + return + + if not tag: # If it has a name use it. if isinstance(obj, anyType) and obj._name: tag = obj._name else: tag = self.gentag() - tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding if isinstance(obj, arrayType): # Array self.dump_list(obj, tag, typed, ns_map) return - - if isinstance(obj, faultType): # Fault + elif isinstance(obj, faultType): # Fault cns, cdecl = self.genns(ns_map, NS.ENC) vns, vdecl = self.genns(ns_map, NS.ENV) self.out.append('<%sFault %sroot="1"%s%s>' % (vns, cns, vdecl, cdecl)) @@ -556,12 +574,11 @@ if isinstance(obj, voidType): # void self.out.append("<%s%s%s></%s>\n" % (tag, a, r, tag)) - return + else: + id = self.checkref(obj, tag, ns_map) + if id == None: + return - id = self.checkref(obj, tag, ns_map) - if id == None: - return - if isinstance(obj, structType): # Check for namespace ndecl = '' @@ -612,13 +629,16 @@ else: # Some Class self.out.append('<%s%s%s>\n' % (tag, id, r)) - for (k, v) in obj.__dict__.items(): - if k[0] != "_": - self.dump(v, k, 1, ns_map) + d1 = getattr(obj, '__dict__', None) + if d1 is not None: + for (k, v) in d1: + if k[0] != "_": + self.dump(v, k, 1, ns_map) self.out.append('</%s>\n' % tag) + ################################################################################ # SOAPBuilder's more public interface ################################################################################ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <poo...@us...> - 2010-03-04 23:46:25
|
Revision: 1496 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1496&view=rev Author: pooryorick Date: 2010-03-04 23:46:17 +0000 (Thu, 04 Mar 2010) Log Message: ----------- Added timeout to client http transport change client attribute lookup so client can be pickled. Modified Paths: -------------- trunk/SOAPpy/SOAPpy/Client.py trunk/SOAPpy/SOAPpy/Types.py Modified: trunk/SOAPpy/SOAPpy/Client.py =================================================================== --- trunk/SOAPpy/SOAPpy/Client.py 2009-08-24 23:40:21 UTC (rev 1495) +++ trunk/SOAPpy/SOAPpy/Client.py 2010-03-04 23:46:17 UTC (rev 1496) @@ -41,8 +41,8 @@ # ################################################################################ """ +ident = '$Id$' -ident = '$Id$' from version import __version__ #import xml.sax @@ -50,6 +50,8 @@ from types import * import re import base64 +import socket, httplib +from httplib import HTTPConnection, HTTP import Cookie # SOAPpy modules @@ -111,7 +113,40 @@ __repr__ = __str__ +class SOAPTimeoutError(socket.timeout): + '''This exception is raised when a timeout occurs in SOAP operations''' + pass +class HTTPConnectionWithTimeout(HTTPConnection): + '''Extend HTTPConnection for timeout support''' + + def __init__(self, host, port=None, strict=None, timeout=None): + HTTPConnection.__init__(self, host, port, strict) + self._timeout = timeout + + def connect(self): + HTTPConnection.connect(self) + if self.sock and self._timeout: + self.sock.settimeout(self._timeout) + + +class HTTPWithTimeout(HTTP): + + _connection_class = HTTPConnectionWithTimeout + + ## this __init__ copied from httplib.HTML class + def __init__(self, host='', port=None, strict=None, timeout=None): + "Provide a default host, since the superclass requires one." + + # some joker passed 0 explicitly, meaning default port + if port == 0: + port = None + + # Note that we may pass an empty string as the host; this will throw + # an error when we attempt to connect. Presumably, the client code + # will call connect before then, with a proper host. + self._setup(self._connection_class(host, port, strict, timeout)) + class HTTPTransport: @@ -149,12 +184,9 @@ attrs.append('$Domain=%s' % value) r.putheader('Cookie', "; ".join(attrs)) - # Need a Timeout someday? def call(self, addr, data, namespace, soapaction = None, encoding = None, - http_proxy = None, config = Config): + http_proxy = None, config = Config, timeout=None): - import httplib - if not isinstance(addr, SOAPAddress): addr = SOAPAddress(addr, config) @@ -172,7 +204,7 @@ elif addr.proto == 'https': r = httplib.HTTPS(real_addr) else: - r = httplib.HTTP(real_addr) + r = HTTPWithTimeout(real_addr, timeout=timeout) r.putrequest("POST", real_path) @@ -309,7 +341,7 @@ header = None, methodattrs = None, transport = HTTPTransport, encoding = 'UTF-8', throw_faults = 1, unwrap_results = None, http_proxy=None, config = Config, noroot = 0, - simplify_objects=None): + simplify_objects=None, timeout=None): # Test the encoding, raising an exception if it's not known if encoding != None: @@ -338,6 +370,7 @@ self.http_proxy = http_proxy self.config = config self.noroot = noroot + self.timeout = timeout # GSI Additions if hasattr(config, "channel_mode") and \ @@ -385,12 +418,15 @@ call_retry = 0 try: - r, self.namespace = self.transport.call(self.proxy, m, ns, sa, encoding = self.encoding, - http_proxy = self.http_proxy, - config = self.config) + http_proxy = self.http_proxy, + config = self.config, + timeout = self.timeout) + except socket.timeout: + raise SOAPTimeoutError + except Exception, ex: # # Call failed. @@ -415,10 +451,14 @@ raise if call_retry: - r, self.namespace = self.transport.call(self.proxy, m, ns, sa, - encoding = self.encoding, - http_proxy = self.http_proxy, - config = self.config) + try: + r, self.namespace = self.transport.call(self.proxy, m, ns, sa, + encoding = self.encoding, + http_proxy = self.http_proxy, + config = self.config, + timeout = self.timeout) + except socket.timeout: + raise SOAPTimeoutError p, attrs = parseSOAPRPC(r, attrs = 1) @@ -465,11 +505,12 @@ return self.__call(None, body, {}) def __getattr__(self, name): # hook to catch method calls - if name == '__del__': + if name in ( '__del__', '__getinitargs__', '__getnewargs__', + '__getstate__', '__setstate__', '__reduce__', '__reduce_ex__'): raise AttributeError, name return self.__Method(self.__call, name, config = self.config) - # To handle attribute wierdness + # To handle attribute weirdness class __Method: # Some magic to bind a SOAP method to an RPC server. # Supports "nested" methods (e.g. examples.getStateName) -- concept Modified: trunk/SOAPpy/SOAPpy/Types.py =================================================================== --- trunk/SOAPpy/SOAPpy/Types.py 2009-08-24 23:40:21 UTC (rev 1495) +++ trunk/SOAPpy/SOAPpy/Types.py 2010-03-04 23:46:17 UTC (rev 1496) @@ -1648,7 +1648,7 @@ def simplify(object, level=0): """ - Convert the SOAPpy objects and thier contents to simple python types. + Convert the SOAPpy objects and their contents to simple python types. This function recursively converts the passed 'container' object, and all public subobjects. (Private subobjects have names that This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-08-24 23:40:34
|
Revision: 1495 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1495&view=rev Author: boverhof Date: 2009-08-24 23:40:21 +0000 (Mon, 24 Aug 2009) Log Message: ----------- M test/wsdl2py/config.txt M test/wsdl2py/test_AWSECommerceService.py -- updated namespace, but RPC returns an error "missing Signature" so I'm catching it then punting for later M ZSI/__init__.py -- _get_default_namespace calls change to key "xmlns" M ZSI/TC.py -- ParsedSoap.GetElementNSDict actually changes key "xmlns" to '', so must use '' to grab default ns Modified Paths: -------------- trunk/zsi/ZSI/TC.py trunk/zsi/ZSI/__init__.py trunk/zsi/test/wsdl2py/config.txt trunk/zsi/test/wsdl2py/test_AWSECommerceService.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2009-08-24 21:55:45 UTC (rev 1494) +++ trunk/zsi/ZSI/TC.py 2009-08-24 23:40:21 UTC (rev 1495) @@ -213,15 +213,8 @@ # Parse the QNAME. prefix,typeName = SplitQName(typeName) - nsdict = ps.GetElementNSdict(elt) - prefix = prefix or '' - - try: - uri = nsdict[prefix] - except KeyError, ex: - raise EvaluateException('cannot resolve prefix(%s)'%prefix, - ps.Backtrace(elt)) - + # Use '' for default namespace with ParsedSoap + uri = ps.GetElementNSdict(elt).get(prefix or '') if uri is None: raise EvaluateException('Malformed type attribute (bad NS)', ps.Backtrace(elt)) Modified: trunk/zsi/ZSI/__init__.py =================================================================== --- trunk/zsi/ZSI/__init__.py 2009-08-24 21:55:45 UTC (rev 1494) +++ trunk/zsi/ZSI/__init__.py 2009-08-24 23:40:21 UTC (rev 1495) @@ -251,6 +251,9 @@ else: if prefix: raise EvaluateException, 'cant resolve xmlns:%s' %prefix + else: + raise EvaluateException, 'cant resolve default namespace' + return namespaceURI def _valid_encoding(elt): Modified: trunk/zsi/test/wsdl2py/config.txt =================================================================== --- trunk/zsi/test/wsdl2py/config.txt 2009-08-24 21:55:45 UTC (rev 1494) +++ trunk/zsi/test/wsdl2py/config.txt 2009-08-24 23:40:21 UTC (rev 1495) @@ -186,6 +186,7 @@ test_NVOAdmin = wsdl/nvo-admin.wsdl test_Clearspace = http://eval.jivesoftware.com/clearspace/rpc/soap/BlogService?wsdl test_VIM = wsdl/vim.wsdl +test_VIM25 = wsdl/vim25/vimService.wsdl test_NoMessagePart = wsdl/NoMessagePart.wsdl Modified: trunk/zsi/test/wsdl2py/test_AWSECommerceService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2009-08-24 21:55:45 UTC (rev 1494) +++ trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2009-08-24 23:40:21 UTC (rev 1495) @@ -43,8 +43,7 @@ -#TargetNamespace = 'http://webservices.amazon.com/AWSECommerceService/2007-10-29' -TargetNamespace = 'http://webservices.amazon.com/AWSECommerceService/2009-02-01' +TargetNamespace = 'http://webservices.amazon.com/AWSECommerceService/2009-07-01' class AmazonTestCase(ServiceTestCase): """Test case for Amazon ECommerce Web service @@ -112,7 +111,11 @@ request.Keywords = 'Tamerlane' request.ResponseGroup = ['Medium',] - response = port.ItemSearch(msg) + try: + response = port.ItemSearch(msg) + except: + # NOTE: Requires a Signature now.. skip rest, returns a soap fault + return response.OperationRequest self.failUnless(response.OperationRequest.Errors is None, 'ecommerce site reported errors') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-05-22 20:42:50
|
Revision: 1493 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1493&view=rev Author: boverhof Date: 2009-05-22 20:42:39 +0000 (Fri, 22 May 2009) Log Message: ----------- M ZSI/TCcompound.py ** comment out very restrictive part of substition code, if "matching" typecodes let it pass and return the substitute Modified Paths: -------------- trunk/zsi/ZSI/TCcompound.py Modified: trunk/zsi/ZSI/TCcompound.py =================================================================== --- trunk/zsi/ZSI/TCcompound.py 2009-05-19 22:40:55 UTC (rev 1492) +++ trunk/zsi/ZSI/TCcompound.py 2009-05-22 20:42:39 UTC (rev 1493) @@ -56,9 +56,10 @@ # Global Element Declaration if isinstance(sub, ElementDeclaration): if (typecode.nspname,typecode.pname) == (sub.nspname,sub.pname): - raise TypeError(\ - 'bad usage, failed to serialize element reference (%s, %s), in: %s' % - (typecode.nspname, typecode.pname, sw.Backtrace(elt),)) + #raise TypeError(\ + # 'bad usage, failed to serialize element reference (%s, %s), in: %s' % + # (typecode.nspname, typecode.pname, sw.Backtrace(elt),)) + return sub # check substitutionGroup if _is_substitute_element(typecode, sub): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-05-19 22:41:02
|
Revision: 1492 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1492&view=rev Author: boverhof Date: 2009-05-19 22:40:55 +0000 (Tue, 19 May 2009) Log Message: ----------- M ZSI/TCcompound.py -- FIX BUG 2794124 TCcomplex Parse algorithm Modified Paths: -------------- trunk/zsi/ZSI/TCcompound.py Modified: trunk/zsi/ZSI/TCcompound.py =================================================================== --- trunk/zsi/ZSI/TCcompound.py 2009-05-18 19:48:29 UTC (rev 1491) +++ trunk/zsi/ZSI/TCcompound.py 2009-05-19 22:40:55 UTC (rev 1492) @@ -185,17 +185,19 @@ if debug: self.logger.debug("ofwhat: %s",str(self.ofwhat)) - any = None - for i,what in [ (i, self.ofwhat[i]) for i in range(len(self.ofwhat)) ]: - - # retrieve typecode if it is hidden - if callable(what): what = what() - - # Loop over all available kids - if debug: - self.logger.debug("what: (%s,%s)", what.nspname, what.pname) - - for j,c_elt in [ (j, c[j]) for j in crange if c[j] ]: + for j,c_elt in [ (j, c[j]) for j in crange if c[j] ]: + for i,what in [ (i, self.ofwhat[i]) for i in range(len(self.ofwhat)) ]: + # Loop over all available kids + if debug: + self.logger.debug("what: (%s,%s)", what.nspname, what.pname) + + # retrieve typecode if it is hidden + if callable(what): what = what() + + # Loop over all available kids + if debug: + self.logger.debug("what: (%s,%s)", what.nspname, what.pname) + # Parse value, and mark this one done. if debug: self.logger.debug("child node: (%s,%s)", c_elt.namespaceURI, c_elt.tagName) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-05-18 19:48:39
|
Revision: 1491 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1491&view=rev Author: boverhof Date: 2009-05-18 19:48:29 +0000 (Mon, 18 May 2009) Log Message: ----------- M test/wsdl2py/wsdl/test_SubstitutionGroup.xsd M ZSI/TCcompound.py Changes: -- formerly: parse all items, set into a dict, then loop on that dict and set all items on pyobj -- now: parse all items, set in pyobj directly, if no pyclass return "pyobj.__dict__" Wildcards (any): -- formerly: parse, then set them last -- now: parse & set them inorder Unittest change: -- was actually wrong since it was an extension of a type that had a wildcard -- remove wildcard declaration in base so "child" can be parsed by the "extension" element Modified Paths: -------------- trunk/zsi/ZSI/TCcompound.py trunk/zsi/test/wsdl2py/wsdl/test_SubstitutionGroup.xsd Modified: trunk/zsi/ZSI/TCcompound.py =================================================================== --- trunk/zsi/ZSI/TCcompound.py 2009-04-27 19:14:49 UTC (rev 1490) +++ trunk/zsi/ZSI/TCcompound.py 2009-05-18 19:48:29 UTC (rev 1491) @@ -92,6 +92,7 @@ elements. ''' logger = _GetLogger('ZSI.TCcompound.ComplexType') + class _DictHolder: pass def __init__(self, pyclass, ofwhat, pname=None, inorder=False, inline=False, mutable=True, mixed=False, mixed_aname='_text', **kw): @@ -156,17 +157,26 @@ if self.nilled(elt, ps): return Nilled # Create the object. - v = {} + if self.pyclass: + # type definition must be informed of element tag (nspname,pname), + # element declaration is initialized with a tag. + try: + pyobj = self.pyclass() + except Exception, e: + raise TypeError("Constructing element (%s,%s) with pyclass(%s), %s" \ + %(self.nspname, self.pname, self.pyclass.__name__, str(e))) + else: + pyobj = ComplexType._DictHolder() # parse all attributes contained in attribute_typecode_dict (user-defined attributes), # the values (if not None) will be keyed in self.attributes dictionary. attributes = self.parse_attributes(elt, ps) if attributes: - v[self.attrs_aname] = attributes + setattr(pyobj, self.attrs_aname, attributes) #MIXED if self.mixed is True: - v[self.mixed_aname] = self.simple_value(elt,ps, mixed=True) + setattr(pyobj, self.mixed_aname, self.simple_value(elt,ps, mixed=True)) # Clone list of kids (we null it out as we process) c, crange = c[:], range(len(c)) @@ -194,6 +204,9 @@ if what.name_match(c_elt): match = True value = what.parse(c_elt, ps) + elif isinstance(what,AnyElement): + match = True + value = what.parse(c_elt, ps) else: # substitutionGroup head must be a global element declaration # if successful delegate to matching GED @@ -207,14 +220,15 @@ if match: if what.maxOccurs > 1: - if v.has_key(what.aname): - v[what.aname].append(value) + attr = getattr(pyobj, what.aname, None) + if attr is not None: + attr.append(value) else: - v[what.aname] = [value] + setattr(pyobj, what.aname, [value]) c[j] = None continue else: - v[what.aname] = value + setattr(pyobj, what.aname, value) c[j] = None break @@ -226,48 +240,15 @@ raise EvaluateException('Out of order complexType', ps.Backtrace(c_elt)) else: - # only supporting 1 <any> declaration in content. - if isinstance(what,AnyElement): - any = what - elif hasattr(what, 'default'): - v[what.aname] = what.default - elif what.minOccurs > 0 and not v.has_key(what.aname): + if hasattr(what, 'default'): + setattr(pyobj, what.aname, what.default) + elif what.minOccurs > 0 and not hasattr(pyobj, what.aname): raise EvaluateException('Element "' + what.aname + \ '" missing from complexType', ps.Backtrace(elt)) - # Look for wildcards and unprocessed children - # XXX Stick all this stuff in "any", hope for no collisions - if any is not None: - occurs = 0 - v[any.aname] = [] - for j,c_elt in [ (j, c[j]) for j in crange if c[j] ]: - value = any.parse(c_elt, ps) - if any.maxOccurs == UNBOUNDED or any.maxOccurs > 1: - v[any.aname].append(value) - else: - v[any.aname] = value + if isinstance(pyobj, ComplexType._DictHolder): + return pyobj.__dict__ - occurs += 1 - - # No such thing as nillable <any> - if any.maxOccurs == 1 and occurs == 0: - v[any.aname] = None - elif occurs < any.minOccurs or (any.maxOccurs!=UNBOUNDED and any.maxOccurs<occurs): - raise EvaluateException('occurances of <any> elements(#%d) bound by (%d,%s)' %( - occurs, any.minOccurs,str(any.maxOccurs)), ps.Backtrace(elt)) - - if not self.pyclass: - return v - - # type definition must be informed of element tag (nspname,pname), - # element declaration is initialized with a tag. - try: - pyobj = self.pyclass() - except Exception, e: - raise TypeError("Constructing element (%s,%s) with pyclass(%s), %s" \ - %(self.nspname, self.pname, self.pyclass.__name__, str(e))) - for key in v.keys(): - setattr(pyobj, key, v[key]) return pyobj def serialize(self, elt, sw, pyobj, inline=False, name=None, **kw): Modified: trunk/zsi/test/wsdl2py/wsdl/test_SubstitutionGroup.xsd =================================================================== --- trunk/zsi/test/wsdl2py/wsdl/test_SubstitutionGroup.xsd 2009-04-27 19:14:49 UTC (rev 1490) +++ trunk/zsi/test/wsdl2py/wsdl/test_SubstitutionGroup.xsd 2009-05-18 19:48:29 UTC (rev 1491) @@ -9,7 +9,6 @@ <xsd:complexType name='baseType'> <xsd:sequence> <xsd:element name="base" type='xsd:string'/> - <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/> </xsd:sequence> </xsd:complexType> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-04-27 19:14:59
|
Revision: 1490 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1490&view=rev Author: boverhof Date: 2009-04-27 19:14:49 +0000 (Mon, 27 Apr 2009) Log Message: ----------- A test/test_AnyType.py M test/test_zsi.py M ZSI/__init__.py M ZSI/TC.py -- FIX BUG [ ZSI.EvaluateException: Any can't parse element - ID: 2762639 ] Modified Paths: -------------- trunk/zsi/ZSI/TC.py trunk/zsi/ZSI/__init__.py trunk/zsi/test/test_zsi.py Added Paths: ----------- trunk/zsi/test/test_AnyType.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2009-04-09 18:46:59 UTC (rev 1489) +++ trunk/zsi/ZSI/TC.py 2009-04-27 19:14:49 UTC (rev 1490) @@ -1465,7 +1465,7 @@ # element declarations prefix, typeName = SplitQName(_find_type(elt)) if not skip and typeName: - namespaceURI = _resolve_prefix(elt, prefix or 'xmlns') + namespaceURI = _resolve_prefix(elt, prefix) # First look thru user defined namespaces, if don't find # look for 'primitives'. pyclass = GTD(namespaceURI, typeName) or Any Modified: trunk/zsi/ZSI/__init__.py =================================================================== --- trunk/zsi/ZSI/__init__.py 2009-04-09 18:46:59 UTC (rev 1489) +++ trunk/zsi/ZSI/__init__.py 2009-04-27 19:14:49 UTC (rev 1490) @@ -224,9 +224,9 @@ _find_type = lambda E: _find_xsi_attr(E, "type") _find_xmlns_prefix = lambda E, attr: E.getAttributeNS(_XMLNS.BASE, attr) -_find_default_namespace = lambda E: E.getAttributeNS(_XMLNS.BASE, None) +_find_default_namespace = lambda E: E.getAttributeNS(_XMLNS.BASE, 'xmlns') -#_textprotect = lambda s: s.replace('&', '&').replace('<', '<') +_textprotect = lambda s: s.replace('&', '&').replace('<', '<') _get_element_nsuri_name = lambda E: (E.namespaceURI, E.localName) Added: trunk/zsi/test/test_AnyType.py =================================================================== --- trunk/zsi/test/test_AnyType.py (rev 0) +++ trunk/zsi/test/test_AnyType.py 2009-04-27 19:14:49 UTC (rev 1490) @@ -0,0 +1,74 @@ +#!/usr/bin/env python +import unittest, sys, tests_good, tests_bad, time +from ZSI import * +try: + import cStringIO as StringIO +except ImportError: + import StringIO + +"""Bug [ 1520092 ] URI Bug: urllib.quote escaping reserved chars + Bug [ 2748314 ] Malformed type attribute (bad NS) with 2.1a1 but not with 2. +""" + +class MyInt_Def(TC.Integer, schema.TypeDefinition): + # ComplexType/SimpleContent derivation of built-in type + schema = "urn:vim25" + type = (schema, "myInt") + def __init__(self, pname, **kw): + self.attribute_typecode_dict = {} + TC.Integer.__init__(self, pname, **kw) + #class Holder(int): + # __metaclass__ = pyclass_type + # typecode = self + #self.pyclass = Holder + self.pyclass = int + +class TestCase(unittest.TestCase): + + def check_type_attribute_qname_in_default_ns(self): + msg = """ +<ns1:test xsi:type="ns1:myInt" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://www.w3.org/2001/XMLSchema"> +100 +</ns1:test>""" + ps = ParsedSoap(msg, envelope=False) + pyobj = ps.Parse(TC.AnyType(pname=("urn:vim25","test"))) + self.failUnless(pyobj == 100, 'failed to parse type in default ns') + + def check_element_in_default_ns(self): + msg = """ +<test xsi:type="myInt" xmlns="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +100 +</test>""" + ps = ParsedSoap(msg, envelope=False) + pyobj = ps.Parse(TC.AnyType(pname=("urn:vim25","test"))) + self.failUnless(pyobj == 100, 'failed to parse element in default ns') + + +# +# Creates permutation of test options: "check", "check_any", etc +# +_SEP = '_' +for t in [i[0].split(_SEP) for i in filter(lambda i: callable(i[1]), TestCase.__dict__.items())]: + test = '' + for f in t: + test += f + if globals().has_key(test): test += _SEP; continue + def _closure(): + name = test + def _makeTestSuite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestCase, name)) + return suite + return _makeTestSuite + + globals()[test] = _closure() + test += _SEP + + +makeTestSuite = check +def main(): + unittest.main(defaultTest="makeTestSuite") +if __name__ == "__main__" : main() + Modified: trunk/zsi/test/test_zsi.py =================================================================== --- trunk/zsi/test/test_zsi.py 2009-04-09 18:46:59 UTC (rev 1489) +++ trunk/zsi/test/test_zsi.py 2009-04-27 19:14:49 UTC (rev 1490) @@ -14,6 +14,7 @@ import test_URI import test_rfc2617 import test_QName +import test_AnyType def makeTestSuite(): return unittest.TestSuite( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-04-09 18:47:02
|
Revision: 1489 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1489&view=rev Author: boverhof Date: 2009-04-09 18:46:59 +0000 (Thu, 09 Apr 2009) Log Message: ----------- M test/test_QName.py -- added unittest for [ pywebsvcs-Bugs-2748314 ] Malformed type attribute (bad NS) with 2.1a1 but not with 2. Modified Paths: -------------- trunk/zsi/test/test_QName.py Modified: trunk/zsi/test/test_QName.py =================================================================== --- trunk/zsi/test/test_QName.py 2009-04-09 18:22:36 UTC (rev 1488) +++ trunk/zsi/test/test_QName.py 2009-04-09 18:46:59 UTC (rev 1489) @@ -8,6 +8,7 @@ """Bug [ 1520092 ] URI Bug: urllib.quote escaping reserved chars + Bug [ 2748314 ] Malformed type attribute (bad NS) with 2.1a1 but not with 2. """ @@ -37,7 +38,17 @@ fault = FaultFromFaultMessage(ps) self.failUnless(fault.code == ('','ServerFaultCode'), 'faultcode should be (namespace,name) tuple') + def check_type_attribute_qname_in_default_ns(self): + msg = """ +<ns1:test xsi:type="int" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://www.w3.org/2001/XMLSchema"> +100 +</ns1:test>""" + ps = ParsedSoap(msg, envelope=False) + pyobj = ps.Parse(TC.Integer(pname=("urn:vim25","test"))) + + # # Creates permutation of test options: "check", "check_any", etc # @@ -64,4 +75,3 @@ unittest.main(defaultTest="makeTestSuite") if __name__ == "__main__" : main() - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-04-09 18:22:40
|
Revision: 1488 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1488&view=rev Author: boverhof Date: 2009-04-09 18:22:36 +0000 (Thu, 09 Apr 2009) Log Message: ----------- M ZSI/TC.py The bug I thought you came across is a known problem with minidom resolving the default namespace. ""Minidom bug in ParsedSoap: Default namespace is empty - ID: 1810600""" But I plugged in 4Suite, without any modifications from my formula ( maybe a versioning difference in regards to 4Suite ), and got the same error. So I looked at TC.py and found the problem, it's trivial, probably occurred as a result of some refactoring since it is correctly handled elsewhere. Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2009-04-07 00:02:42 UTC (rev 1487) +++ trunk/zsi/ZSI/TC.py 2009-04-09 18:22:36 UTC (rev 1488) @@ -213,7 +213,15 @@ # Parse the QNAME. prefix,typeName = SplitQName(typeName) - uri = ps.GetElementNSdict(elt).get(prefix) + nsdict = ps.GetElementNSdict(elt) + prefix = prefix or '' + + try: + uri = nsdict[prefix] + except KeyError, ex: + raise EvaluateException('cannot resolve prefix(%s)'%prefix, + ps.Backtrace(elt)) + if uri is None: raise EvaluateException('Malformed type attribute (bad NS)', ps.Backtrace(elt)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-04-07 00:02:46
|
Revision: 1487 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1487&view=rev Author: lclement Date: 2009-04-07 00:02:42 +0000 (Tue, 07 Apr 2009) Log Message: ----------- Bug fix in the file attachment... Modified Paths: -------------- trunk/zsi/ZSI/TCapache.py trunk/zsi/ZSI/generate/containers.py trunk/zsi/ZSI/typeinterpreter.py Modified: trunk/zsi/ZSI/TCapache.py =================================================================== --- trunk/zsi/ZSI/TCapache.py 2009-04-07 00:02:02 UTC (rev 1486) +++ trunk/zsi/ZSI/TCapache.py 2009-04-07 00:02:42 UTC (rev 1487) @@ -6,10 +6,11 @@ from ZSI import _copyright, _child_elements, _get_idstr from ZSI.TC import SimpleType, TypeCode, Struct as _Struct, Any as _Any from ZSI.wstools.logging import getLogger as _GetLogger +from ZSI.wstools.Namespaces import APACHE #import types class Apache: - NS = "http://xml.apache.org/xml-soap" + NS = APACHE.AXIS_NS class _Map(TypeCode): '''Apache's "Map" type. Modified: trunk/zsi/ZSI/generate/containers.py =================================================================== --- trunk/zsi/ZSI/generate/containers.py 2009-04-07 00:02:02 UTC (rev 1486) +++ trunk/zsi/ZSI/generate/containers.py 2009-04-07 00:02:42 UTC (rev 1487) @@ -14,7 +14,7 @@ import ZSI from ZSI.TC import _is_xsd_or_soap_ns from ZSI.wstools import XMLSchema, WSDLTools -from ZSI.wstools.Namespaces import SCHEMA, SOAP, WSDL +from ZSI.wstools.Namespaces import SCHEMA, SOAP, WSDL, APACHE from ZSI.wstools.logging import getLogger as _GetLogger from ZSI.typeinterpreter import BaseTypeInterpreter from ZSI.generate import WSISpec, WSInteropError, Wsdl2PythonError,\ @@ -1627,7 +1627,8 @@ elif global_type is not None: tc.name = c.getAttribute('name') ns = global_type[0] - if ns in SCHEMA.XSD_LIST: + #APACHE.AXIS_NS is for DataHandler type + if ns in SCHEMA.XSD_LIST + [APACHE.AXIS_NS]: tpc = BTI.get_typeclass(global_type[1],global_type[0]) tc.klass = tpc # elif (self.ns,self.name) == global_type: @@ -1775,7 +1776,7 @@ tc = RPCMessageTcListComponentContainer(qualified=False) tc.setOccurs(min, max, nil) tc.name = p.name - if nsuri in [SOAP.ENC] + SCHEMA.XSD_LIST: + if nsuri in XMLSchema.BUILT_IN_NAMESPACES: tpc = BTI.get_typeclass(name, nsuri) tc.klass = tpc else: Modified: trunk/zsi/ZSI/typeinterpreter.py =================================================================== --- trunk/zsi/ZSI/typeinterpreter.py 2009-04-07 00:02:02 UTC (rev 1486) +++ trunk/zsi/ZSI/typeinterpreter.py 2009-04-07 00:02:42 UTC (rev 1487) @@ -87,7 +87,7 @@ if untaged_xsd_types.has_key(msg_type): return untaged_xsd_types[msg_type] for tc in self._type_list: - if tc.type == (SCHEMA.XSD3,msg_type) or tc.type == (SCHEMA.AXIS,msg_type): + if tc.type == (SCHEMA.XSD3,msg_type): break else: tc = TC.AnyType @@ -107,6 +107,14 @@ return self._get_xsd_typecode(name) elif targetNamespace in [SOAP.ENC]: return self._get_soapenc_typecode(name) + elif targetNamespace in [ZSI.TCapache.Apache.NS]: + #maybe we have an AXIS attachment + if name == ZSI.TCapache.AttachmentRef.type[1]: + #we have an AXIS attachment + return ZSI.TCapache.AttachmentRef + else: + #AXIS Map type + return TC.AnyType return None def get_pythontype(self, msg_type, targetNamespace, typeclass=None): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-04-07 00:02:17
|
Revision: 1486 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1486&view=rev Author: lclement Date: 2009-04-07 00:02:02 +0000 (Tue, 07 Apr 2009) Log Message: ----------- Bug fix in the File attachment Modified Paths: -------------- trunk/wstools/Namespaces.py trunk/wstools/XMLSchema.py Modified: trunk/wstools/Namespaces.py =================================================================== --- trunk/wstools/Namespaces.py 2009-04-02 01:08:10 UTC (rev 1485) +++ trunk/wstools/Namespaces.py 2009-04-07 00:02:02 UTC (rev 1486) @@ -24,9 +24,7 @@ XSD1 = "http://www.w3.org/1999/XMLSchema" XSD2 = "http://www.w3.org/2000/10/XMLSchema" XSD3 = "http://www.w3.org/2001/XMLSchema" - #AXIS attachment implementation details - AXIS = "http://xml.apache.org/xml-soap" - XSD_LIST = [ XSD1, XSD2, XSD3, AXIS] + XSD_LIST = [ XSD1, XSD2, XSD3] XSI1 = "http://www.w3.org/1999/XMLSchema-instance" XSI2 = "http://www.w3.org/2000/10/XMLSchema-instance" XSI3 = "http://www.w3.org/2001/XMLSchema-instance" @@ -142,6 +140,13 @@ BASEFAULTS = WSRF_V1_2.BASEFAULTS.XSD_DRAFT1 +class APACHE: + '''This name space is defined by AXIS and it is used for the TC in TCapache.py, + Map and file attachment (DataHandler) + ''' + AXIS_NS = "http://xml.apache.org/xml-soap" + + class WSTRUST: BASE = "http://schemas.xmlsoap.org/ws/2004/04/trust" ISSUE = "http://schemas.xmlsoap.org/ws/2004/04/trust/Issue" Modified: trunk/wstools/XMLSchema.py =================================================================== --- trunk/wstools/XMLSchema.py 2009-04-02 01:08:10 UTC (rev 1485) +++ trunk/wstools/XMLSchema.py 2009-04-07 00:02:02 UTC (rev 1486) @@ -15,7 +15,7 @@ ident = "$Id$" import types, weakref, sys, warnings -from Namespaces import SCHEMA, XMLNS, SOAP +from Namespaces import SCHEMA, XMLNS, SOAP, APACHE from Utility import DOM, DOMException, Collection, SplitQName, basejoin from StringIO import StringIO @@ -37,7 +37,7 @@ ATTRIBUTES = 'attr_decl' ELEMENTS = 'elements' MODEL_GROUPS = 'model_groups' -BUILT_IN_NAMESPACES = [SOAP.ENC,] + SCHEMA.XSD_LIST +BUILT_IN_NAMESPACES = [SOAP.ENC,] + SCHEMA.XSD_LIST + [APACHE.AXIS_NS] def GetSchema(component): """convience function for finding the parent XMLSchema instance. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-04-02 01:08:12
|
Revision: 1485 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1485&view=rev Author: lclement Date: 2009-04-02 01:08:10 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Fixed a couple of tests Modified Paths: -------------- trunk/zsi/test/wsdl2py/config.txt trunk/zsi/test/wsdl2py/test_AWSECommerceService.py trunk/zsi/test/wsdl2py/test_ThreatService.py Modified: trunk/zsi/test/wsdl2py/config.txt =================================================================== --- trunk/zsi/test/wsdl2py/config.txt 2009-03-31 22:10:10 UTC (rev 1484) +++ trunk/zsi/test/wsdl2py/config.txt 2009-04-02 01:08:10 UTC (rev 1485) @@ -75,7 +75,9 @@ document = False literal = False broke = False -tests = test_XMethodsQuery test_ThreatService +tests = test_ThreatService +#XMethods web site is broken wsdl can not be retreived +#tests = test_XMethodsQuery test_ThreatService [rpc_encoded_broke] document = False Modified: trunk/zsi/test/wsdl2py/test_AWSECommerceService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2009-03-31 22:10:10 UTC (rev 1484) +++ trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2009-04-02 01:08:10 UTC (rev 1485) @@ -42,8 +42,10 @@ return suite -TargetNamespace = 'http://webservices.amazon.com/AWSECommerceService/2007-10-29' +#TargetNamespace = 'http://webservices.amazon.com/AWSECommerceService/2007-10-29' +TargetNamespace = 'http://webservices.amazon.com/AWSECommerceService/2009-02-01' + class AmazonTestCase(ServiceTestCase): """Test case for Amazon ECommerce Web service """ @@ -117,12 +119,12 @@ response.OperationRequest.Arguments for i in response.OperationRequest.Arguments.Argument: - i.get_attribute_Name() - i.get_attribute_Value() - - for i in response.OperationRequest.HTTPHeaders.Header or []: - i.get_attribute_Name() - i.get_attribute_Value() + i.get_attribute_Name() + i.get_attribute_Value() + if response.OperationRequest.HTTPHeaders: + for i in response.OperationRequest.HTTPHeaders.Header or []: + i.get_attribute_Name() + i.get_attribute_Value() response.OperationRequest.RequestId response.OperationRequest.RequestProcessingTime Modified: trunk/zsi/test/wsdl2py/test_ThreatService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_ThreatService.py 2009-03-31 22:10:10 UTC (rev 1484) +++ trunk/zsi/test/wsdl2py/test_ThreatService.py 2009-04-02 01:08:10 UTC (rev 1485) @@ -59,8 +59,8 @@ msg = self.client_module.threatLevelRequest() rsp = port.threatLevel(msg) for item in rsp.ThreatLevelReturn.Item: - item.Key - item.Value + item['key'] + item['value'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-03-31 22:10:21
|
Revision: 1484 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1484&view=rev Author: lclement Date: 2009-03-31 22:10:10 +0000 (Tue, 31 Mar 2009) Log Message: ----------- Some preliminary unit test for the Attachment implementation. Modified Paths: -------------- trunk/zsi/test/wsdl2py/config.txt Added Paths: ----------- trunk/zsi/test/wsdl2py/test_Attachment.py trunk/zsi/test/wsdl2py/wsdl/test_Attachment.wsdl Modified: trunk/zsi/test/wsdl2py/config.txt =================================================================== --- trunk/zsi/test/wsdl2py/config.txt 2009-03-31 18:27:55 UTC (rev 1483) +++ trunk/zsi/test/wsdl2py/config.txt 2009-03-31 22:10:10 UTC (rev 1484) @@ -119,7 +119,7 @@ document = True literal = True broke = False -tests = test_MapPoint test_Echo test_AWSECommerceService test_FinancialService test_BasicComm test_Manufacturer test_Racing test_Attributes test_Choice test_DerivedTypes test_EchoWSAddr200403 test_SubstitutionGroup test_VIM test_Unqualified test_NoMessagePart +tests = test_Attachment test_MapPoint test_Echo test_AWSECommerceService test_FinancialService test_BasicComm test_Manufacturer test_Racing test_Attributes test_Choice test_DerivedTypes test_EchoWSAddr200403 test_SubstitutionGroup test_VIM test_Unqualified test_NoMessagePart [doc_literal_broke] document = True @@ -186,3 +186,6 @@ test_VIM = wsdl/vim.wsdl test_NoMessagePart = wsdl/NoMessagePart.wsdl + +test_Attachment = wsdl/test_Attachment.wsdl + Added: trunk/zsi/test/wsdl2py/test_Attachment.py =================================================================== --- trunk/zsi/test/wsdl2py/test_Attachment.py (rev 0) +++ trunk/zsi/test/wsdl2py/test_Attachment.py 2009-03-31 22:10:10 UTC (rev 1484) @@ -0,0 +1,70 @@ +#!/usr/bin/env python +############################################################################ +# Joshua R. Boverhof, LBNL +# See LBNLCopyright for copyright notice! +########################################################################### +import os, sys, unittest +from ServiceTest import main, ServiceTestCase, ServiceTestSuite +from ZSI import FaultException, ParsedSoap, SoapWriter + +""" +Unittest + +WSDL: +""" + +# General targets +def dispatch(): + """Run all dispatch tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(TestCase, 'test_dispatch')) + return suite + +def local(): + """Run all local tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(TestCase, 'test_local')) + return suite + +def net(): + """Run all network tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(TestCase, 'test_net')) + return suite + +def all(): + """Run all tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(TestCase, 'test_')) + return suite + + +class TestCase(ServiceTestCase): + name = "test_Attachment" + client_file_name = "TestService_client.py" + types_file_name = "TestService_types.py" + server_file_name = "TestService_server.py" + + def __init__(self, methodName): + ServiceTestCase.__init__(self, methodName) + self.wsdl2py_args.append('-b') + + def test_local_generateMessageAttachment(self): + """doc/lit, generating a message using MIME attachment, + we don't have the server side implementation so we can + really do a full test yet + """ + from TestService_server import uploadFileRequest + #stubs were properly generated + request = uploadFileRequest() + request._name = "TestService_client.py" + request._attachment = open("stubs/TestService_client.py", 'r') + sw = SoapWriter({}, header=True, outputclass=None, encodingStyle=None) + sw.serialize(request) + print "the request message is: " + str(sw) + #there is not server side, so for the moment we just create the message and print it on screen + #TODO add server side implmementation + + +if __name__ == "__main__" : + main() Added: trunk/zsi/test/wsdl2py/wsdl/test_Attachment.wsdl =================================================================== --- trunk/zsi/test/wsdl2py/wsdl/test_Attachment.wsdl (rev 0) +++ trunk/zsi/test/wsdl2py/wsdl/test_Attachment.wsdl 2009-03-31 22:10:10 UTC (rev 1484) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<wsdl:definitions targetNamespace="http://nbcr.sdsc.edu/opal" + xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://nbcr.sdsc.edu/opal" + xmlns:intf="http://nbcr.sdsc.edu/opal" xmlns:tns1="http://nbcr.sdsc.edu/opal/types" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <wsdl:types> + <schema targetNamespace="http://nbcr.sdsc.edu/opal/types" xmlns="http://www.w3.org/2001/XMLSchema"> + <import namespace="http://xml.apache.org/xml-soap"/> + + + <complexType name="InputFileType"> + <sequence> + <element name="name" type="xsd:string"/> + <element maxOccurs="1" minOccurs="0" name="attachment" type="apachesoap:DataHandler"/> + </sequence> + </complexType> + + + <element name="uploadFileInput" type="tns1:InputFileType"/> + <element name="uploadFileOutput" type="xsd:string"/> + + </schema> + </wsdl:types> + <wsdl:message name="uploadFileRequest"> + <wsdl:part element="tns1:uploadFileInput" name="uploadFileInput"/> + </wsdl:message> + + <wsdl:message name="uploadFileResponse"> + <wsdl:part element="tns1:uploadFileOutput" name="uploadFileOutput"/> + </wsdl:message> + + <wsdl:portType name="TestServicePortType"> + <wsdl:operation name="uploadFile" parameterOrder="uploadFileInput"> + <wsdl:input message="impl:uploadFileRequest" name="uploadFileRequest"/> + <wsdl:output message="impl:uploadFileResponse" name="uploadFileResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="TestServicePortSoapBinding" type="impl:TestServicePortType"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="uploadFile"> + <wsdlsoap:operation soapAction="http://nbcr.sdsc.edu/opal/uploadFile"/> + <wsdl:input name="uploadFileRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="uploadFileResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="TestService"> + <wsdl:port binding="impl:TestServicePortSoapBinding" name="TestServicePort"> + <wsdlsoap:address location="http://localhost:8080/opal2/services/CAT"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-03-31 18:28:00
|
Revision: 1483 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1483&view=rev Author: lclement Date: 2009-03-31 18:27:55 +0000 (Tue, 31 Mar 2009) Log Message: ----------- Added binary attachment support (client only) Modified Paths: -------------- trunk/wstools/Namespaces.py trunk/wstools/Utility.py Added Paths: ----------- trunk/wstools/MIMEAttachment.py Added: trunk/wstools/MIMEAttachment.py =================================================================== --- trunk/wstools/MIMEAttachment.py (rev 0) +++ trunk/wstools/MIMEAttachment.py 2009-03-31 18:27:55 UTC (rev 1483) @@ -0,0 +1,110 @@ +#TODO add the license +#I had to rewrite this class because the python MIME email.mime (version 2.5) +#are buggy, they use \n instead \r\n for new line which is not compliant +#to standard! +# http://bugs.python.org/issue5525 + +#TODO do not load all the message in memory stream it from the disk + +import re +import random +import sys + + +#new line +NL='\r\n' + +_width = len(repr(sys.maxint-1)) +_fmt = '%%0%dd' % _width + +class MIMEMessage: + + def __init__(self): + self._files = [] + self._xmlMessage = "" + self._startCID = "" + self._boundary = "" + + def makeBoundary(self): + #create the boundary + msgparts = [] + msgparts.append(self._xmlMessage) + for i in self._files: + msgparts.append(i.read()) + #this sucks, all in memory + alltext = NL.join(msgparts) + self._boundary = _make_boundary(alltext) + #maybe I can save some memory + del alltext + del msgparts + self._startCID = "<" + (_fmt % random.randrange(sys.maxint)) + (_fmt % random.randrange(sys.maxint)) + ">" + + + def toString(self): + '''it return a string with the MIME message''' + if len(self._boundary) == 0: + #the makeBoundary hasn't been called yet + self.makeBoundary() + #ok we have everything let's start to spit the message out + #first the XML + returnstr = NL + "--" + self._boundary + NL + returnstr += "Content-Type: text/xml; charset=\"us-ascii\"" + NL + returnstr += "Content-Transfer-Encoding: 7bit" + NL + returnstr += "Content-Id: " + self._startCID + NL + NL + returnstr += self._xmlMessage + NL + #then the files + for file in self._files: + returnstr += "--" + self._boundary + NL + returnstr += "Content-Type: application/octet-stream" + NL + returnstr += "Content-Transfer-Encoding: binary" + NL + returnstr += "Content-Id: <" + str(id(file)) + ">" + NL + NL + file.seek(0) + returnstr += file.read() + NL + #closing boundary + returnstr += "--" + self._boundary + "--" + NL + return returnstr + + def attachFile(self, file): + ''' + it adds a file to this attachment + ''' + self._files.append(file) + + def addXMLMessage(self, xmlMessage): + ''' + it adds the XML message. we can have only one XML SOAP message + ''' + self._xmlMessage = xmlMessage + + def getBoundary(self): + ''' + this function returns the string used in the mime message as a + boundary. First the write method as to be called + ''' + return self._boundary + + def getStartCID(self): + ''' + This function returns the CID of the XML message + ''' + return self._startCID + + +def _make_boundary(text=None): + #some code taken from python stdlib + # Craft a random boundary. If text is given, ensure that the chosen + # boundary doesn't appear in the text. + token = random.randrange(sys.maxint) + boundary = ('=' * 10) + (_fmt % token) + '==' + if text is None: + return boundary + b = boundary + counter = 0 + while True: + cre = re.compile('^--' + re.escape(b) + '(--)?$', re.MULTILINE) + if not cre.search(text): + break + b = boundary + '.' + str(counter) + counter += 1 + return b + Modified: trunk/wstools/Namespaces.py =================================================================== --- trunk/wstools/Namespaces.py 2009-03-31 18:27:03 UTC (rev 1482) +++ trunk/wstools/Namespaces.py 2009-03-31 18:27:55 UTC (rev 1483) @@ -24,7 +24,9 @@ XSD1 = "http://www.w3.org/1999/XMLSchema" XSD2 = "http://www.w3.org/2000/10/XMLSchema" XSD3 = "http://www.w3.org/2001/XMLSchema" - XSD_LIST = [ XSD1, XSD2, XSD3 ] + #AXIS attachment implementation details + AXIS = "http://xml.apache.org/xml-soap" + XSD_LIST = [ XSD1, XSD2, XSD3, AXIS] XSI1 = "http://www.w3.org/1999/XMLSchema-instance" XSI2 = "http://www.w3.org/2000/10/XMLSchema-instance" XSI3 = "http://www.w3.org/2001/XMLSchema-instance" Modified: trunk/wstools/Utility.py =================================================================== --- trunk/wstools/Utility.py 2009-03-31 18:27:03 UTC (rev 1482) +++ trunk/wstools/Utility.py 2009-03-31 18:27:55 UTC (rev 1483) @@ -976,6 +976,7 @@ def createAttributeNS(self, namespace, name, value): document = self._getOwnerDocument() + ##this function doesn't exist!! it has only two arguments attrNode = document.createAttributeNS(namespace, name, value) def setAttributeNS(self, namespaceURI, localName, value): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lcl...@us...> - 2009-03-31 18:27:11
|
Revision: 1482 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1482&view=rev Author: lclement Date: 2009-03-31 18:27:03 +0000 (Tue, 31 Mar 2009) Log Message: ----------- Added binary attachment support (only cliend side). Modified Paths: -------------- trunk/zsi/CHANGES trunk/zsi/ZSI/TCapache.py trunk/zsi/ZSI/client.py trunk/zsi/ZSI/typeinterpreter.py trunk/zsi/ZSI/writer.py trunk/zsi/test/test_t8.py Modified: trunk/zsi/CHANGES =================================================================== --- trunk/zsi/CHANGES 2009-02-10 20:05:51 UTC (rev 1481) +++ trunk/zsi/CHANGES 2009-03-31 18:27:03 UTC (rev 1482) @@ -5,6 +5,8 @@ - In SoapWriter, put nsdecls on body, not envelope - Record facets (restrictions) in XMLSchema.py <vc...@da...> - Remove Send()'s kwargs out of _args list <ef...@bo...> + - Added support for file attachment using AXIS apachesoap:DataHandler to + reference it in the WSDL (only client side) lcl...@sf... Change for 2.1.0_a1 released 31-Oct-2007: - No PyXML Dependency, use minidom by default (much faster) Modified: trunk/zsi/ZSI/TCapache.py =================================================================== --- trunk/zsi/ZSI/TCapache.py 2009-02-10 20:05:51 UTC (rev 1481) +++ trunk/zsi/ZSI/TCapache.py 2009-03-31 18:27:03 UTC (rev 1482) @@ -4,7 +4,9 @@ ''' from ZSI import _copyright, _child_elements, _get_idstr -from ZSI.TC import TypeCode, Struct as _Struct, Any as _Any +from ZSI.TC import SimpleType, TypeCode, Struct as _Struct, Any as _Any +from ZSI.wstools.logging import getLogger as _GetLogger +#import types class Apache: NS = "http://xml.apache.org/xml-soap" @@ -70,6 +72,54 @@ self.tc.serialize(el, sw, {'key': k, 'value': v}, name='item') +class AttachmentRef(SimpleType): + '''Type code for Attachment. This attachment will work only with axis... + ''' + + logger = _GetLogger('ZSI.TC.Attachment') + type = (Apache.NS, "DataHandler") + parselist = [(Apache.NS, "DataHandler")] + #seriallist = [ types.FileType ] + + def __init__(self, pname=None, format='%s', **kw): + TypeCode.__init__(self, pname, **kw) + self.format = format + + + def parse(self, elt, ps): + #never invoked ??? + #print "elt is: " + str(elt) + #print "while ps: " + str(ps) + return + + def get_formatted_content(self, pyobj): + return self.format %pyobj + + def serialize(self, elt, sw, pyobj, name=None, orig=None, **kw): + '''This function is in charge of serializing the attachment + fist it add the <attachment href=""/> tag + then it wraps up everything + + pyobj is the file descriptor pointing to the file we wanna attach + elt is the ElementProxy containing the <inputFile> tag with the attachment tag + sw SoapWriter + ''' + #print "serialize called with pyobj: " + str(pyobj) + #adding the attachment tag + if pyobj is None: + return + if not sw.Known(pyobj): + sw.addAttachment(pyobj) + idhref = id(pyobj) + attachmentElement = elt.createAppendElement(None, "attachment", prefix="") + attachmentElement.setAttributeNS(None, "href", "cid:" + str(idhref)) + else: + #print "the file " + pyobj + " was already attached" + #do nothing + #this should not happen + pass + + Apache.Map = _Map if __name__ == '__main__': print _copyright Modified: trunk/zsi/ZSI/client.py =================================================================== --- trunk/zsi/ZSI/client.py 2009-02-10 20:05:51 UTC (rev 1481) +++ trunk/zsi/ZSI/client.py 2009-03-31 18:27:03 UTC (rev 1482) @@ -289,6 +289,8 @@ soapdata = str(sw) self.h = transport(netloc, None, **self.transdict) self.h.connect() + self.boundary = sw.getMIMEBoundary() + self.startCID = sw.getStartCID() self.SendSOAPData(soapdata, url, soapaction, **kw) def SendSOAPData(self, soapdata, url, soapaction, headers={}, **kw): @@ -301,7 +303,13 @@ request_uri = _get_postvalue_from_absoluteURI(url) self.h.putrequest("POST", request_uri) self.h.putheader("Content-Length", "%d" % len(soapdata)) - self.h.putheader("Content-Type", 'text/xml; charset="%s"' %UNICODE_ENCODING) + if len(self.boundary) == 0: + #no attachment + self.h.putheader("Content-Type", 'text/xml; charset="%s"' %UNICODE_ENCODING) + else: + #we have attachment + contentType = "multipart/related; " + self.h.putheader("Content-Type" , "multipart/related; boundary=\"" + self.boundary + "\"; start=\"" + self.startCID + '\"; type="text/xml"') self.__addcookies() for header,value in headers.items(): Modified: trunk/zsi/ZSI/typeinterpreter.py =================================================================== --- trunk/zsi/ZSI/typeinterpreter.py 2009-02-10 20:05:51 UTC (rev 1481) +++ trunk/zsi/ZSI/typeinterpreter.py 2009-03-31 18:27:03 UTC (rev 1482) @@ -31,7 +31,7 @@ TC.gMonthDay, TC.InonPositiveInteger, \ TC.Ibyte, TC.FPdouble, TC.gTime, TC.gYear, \ TC.Ilong, TC.IunsignedLong, TC.Ishort, \ - TC.Token, TC.QName] + TC.Token, TC.QName, ZSI.TCapache.AttachmentRef] self._tc_to_int = [ ZSI.TCnumbers.IEnumeration, @@ -63,7 +63,8 @@ ZSI.TC.String, ZSI.TC.URI, ZSI.TC.XMLString, - ZSI.TC.Token] + ZSI.TC.Token, + ZSI.TCapache.AttachmentRef] self._tc_to_tuple = [ ZSI.TC.Duration, @@ -86,7 +87,7 @@ if untaged_xsd_types.has_key(msg_type): return untaged_xsd_types[msg_type] for tc in self._type_list: - if tc.type == (SCHEMA.XSD3,msg_type): + if tc.type == (SCHEMA.XSD3,msg_type) or tc.type == (SCHEMA.AXIS,msg_type): break else: tc = TC.AnyType Modified: trunk/zsi/ZSI/writer.py =================================================================== --- trunk/zsi/ZSI/writer.py 2009-02-10 20:05:51 UTC (rev 1481) +++ trunk/zsi/ZSI/writer.py 2009-03-31 18:27:03 UTC (rev 1482) @@ -8,6 +8,8 @@ from ZSI.wstools.Utility import MessageInterface, ElementProxy from ZSI.wstools.Namespaces import XMLNS, SOAP, SCHEMA from ZSI.wstools.c14n import Canonicalize +from ZSI.wstools.MIMEAttachment import MIMEMessage + import types _standard_ns = [ ('xml', XMLNS.XML), ('xmlns', XMLNS.BASE) ] @@ -46,11 +48,36 @@ self.body = None self.callbacks = [] self.closed = False + self._attachments = [] + self._MIMEBoundary = "" + self._startCID = "" def __str__(self): self.close() - return str(self.dom) + if len(self._attachments) == 0: + #we have no attachment let's return the SOAP message + return str(self.dom) + else: + #we have some files to attach let's create the MIME message + #first part the SOAP message + msg = MIMEMessage() + msg.addXMLMessage(str(self.dom)) + for file in self._attachments: + msg.attachFile(file) + msg.makeBoundary() + self._MIMEBoundary = msg.getBoundary() + self._startCID = msg.getStartCID() + return msg.toString() + def getMIMEBoundary(self): + #return the httpHeader if any + return self._MIMEBoundary + + def getStartCID(self): + #return the CID of the xml part + return self._startCID + + def getSOAPHeader(self): if self.header in (True, False): return None @@ -120,7 +147,7 @@ if root not in [ 0, 1 ]: raise ValueError, "SOAP-ENC root attribute not in [0,1]" elt.setAttributeNS(SOAP.ENC, 'root', root) - + return self def writeNSdict(self, nsdict): @@ -175,6 +202,12 @@ ''' return _backtrace(elt._getNode(), self.dom._getNode()) + + def addAttachment(self, fileDesc): + '''This function add an attachment to the SaopMessage + ''' + self._attachments.append(fileDesc) + def close(self): '''Invoke all the callbacks, and close off the SOAP message. ''' Modified: trunk/zsi/test/test_t8.py =================================================================== --- trunk/zsi/test/test_t8.py 2009-02-10 20:05:51 UTC (rev 1481) +++ trunk/zsi/test/test_t8.py 2009-03-31 18:27:03 UTC (rev 1482) @@ -1,6 +1,6 @@ #!/usr/bin/env python import unittest, sys, types, time -from ZSI import TC, SoapWriter, ParsedSoap, EvaluateException +from ZSI import TC, SoapWriter, ParsedSoap, EvaluateException, TCapache from ZSI.wstools.Namespaces import SCHEMA, SOAP NSDICT = {'tns':'xmlns:tns="urn:a"', @@ -31,7 +31,7 @@ def check_parse_empty_all(self): # None - skip = [TC.FPEnumeration, TC.Enumeration, TC.IEnumeration, TC.List, TC.Integer] + skip = [TC.FPEnumeration, TC.Enumeration, TC.IEnumeration, TC.List, TC.Integer, TCapache.AttachmentRef] for typeclass in filter(lambda c: type(c) in [types.ClassType,type] and not issubclass(c, TC.String) and issubclass(c, TC.SimpleType), TC.__dict__.values()): if typeclass in skip: continue tc = typeclass() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bov...@us...> - 2009-02-10 20:06:04
|
Revision: 1481 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1481&view=rev Author: boverhof Date: 2009-02-10 20:05:51 +0000 (Tue, 10 Feb 2009) Log Message: ----------- M XMLSchema.py -- fix for bug report "[ 2586279 ] annotation IndexError" Modified Paths: -------------- trunk/wstools/XMLSchema.py Modified: trunk/wstools/XMLSchema.py =================================================================== --- trunk/wstools/XMLSchema.py 2009-01-07 20:47:37 UTC (rev 1480) +++ trunk/wstools/XMLSchema.py 2009-02-10 20:05:51 UTC (rev 1481) @@ -2471,7 +2471,8 @@ self.annotation = Annotation(self) self.annotation.fromDom(contents[indx]) indx += 1 - component = SplitQName(contents[indx].getTagName())[1] + if indx < num: + component = SplitQName(contents[indx].getTagName())[1] self.content = None if component == 'simpleContent': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2009-01-07 20:47:40
|
Revision: 1480 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1480&view=rev Author: psha Date: 2009-01-07 20:47:37 +0000 (Wed, 07 Jan 2009) Log Message: ----------- Added test case for small year from bugreport Modified Paths: -------------- trunk/zsi/test/test_TCtimes.py Modified: trunk/zsi/test/test_TCtimes.py =================================================================== --- trunk/zsi/test/test_TCtimes.py 2009-01-07 20:46:41 UTC (rev 1479) +++ trunk/zsi/test/test_TCtimes.py 2009-01-07 20:47:37 UTC (rev 1480) @@ -1,4 +1,6 @@ #!/usr/bin/env python +# vim: sts=4 sw=4 et + import unittest, sys, tests_good, tests_bad, time, os from ZSI import * try: @@ -15,6 +17,7 @@ def _check_data2data(self, tc, data, correct, msg): tmp = tc.text_to_data(data, None, None) stamp = tc.get_formatted_content(tmp) + #print "%s -> %s" % (data, str(tmp)) self.failUnless(stamp == correct, '%s with local offset(%s): expecting "%s" got "%s"' %( @@ -31,6 +34,12 @@ os.environ['TZ'] = oldtz time.tzset() + def _check_minimum(self): + data = "0001-01-01T00:00:00.0000000-07:00" + tc = TC.gDateTime() + tc.text_to_data(data, None, None) + check_minimum = lambda s: s._wrap_timezone(s._check_minimum) + def _check_datetime_timezone(self): # UTC with local timezone offset # Base example from http://www.w3.org/TR/xmlschema11-2/#dateTime-lexical-mapping This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2009-01-07 20:46:49
|
Revision: 1479 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1479&view=rev Author: psha Date: 2009-01-07 20:46:41 +0000 (Wed, 07 Jan 2009) Log Message: ----------- Increase borders when timezone is ignored (MINYEAR+1, MAXYEAR-1) Always reintialize timezone offsets Modified Paths: -------------- trunk/zsi/ZSI/TCtimes.py Modified: trunk/zsi/ZSI/TCtimes.py =================================================================== --- trunk/zsi/ZSI/TCtimes.py 2009-01-06 23:45:51 UTC (rev 1478) +++ trunk/zsi/ZSI/TCtimes.py 2009-01-07 20:46:41 UTC (rev 1479) @@ -17,17 +17,20 @@ #### Code added to check current timezone offset _zero = _timedelta(0) -_dstoffset = _stdoffset = _timedelta(seconds=-_time.timezone) -if _time.daylight: _dstoffset = _timedelta(seconds=-_time.altzone) -_dstdiff = _dstoffset - _stdoffset class _localtimezone(_tzinfo): + def __init__(self, *a, **kw): + _tzinfo.__init__(self, *a, **kw) + self.__dstoffset = self.__stdoffset = _timedelta(seconds=-_time.timezone) + if _time.daylight: self.__dstoffset = _timedelta(seconds=-_time.altzone) + self.__dstdiff = self.__dstoffset - self.__stdoffset + """ """ def dst(self, dt): """datetime -> DST offset in minutes east of UTC.""" tt = _localtime(_mktime((dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1))) - if tt.tm_isdst > 0: return _dstdiff + if tt.tm_isdst > 0: return self.__dstdiff return _zero #def fromutc(...) @@ -43,8 +46,8 @@ """datetime -> minutes east of UTC (negative for west of UTC).""" tt = _localtime(_mktime((dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1))) - if tt.tm_isdst > 0: return _dstoffset - return _stdoffset + if tt.tm_isdst > 0: return self.__dstoffset + return self.__stdoffset class _fixedoffset(_tzinfo): """Fixed offset in minutes east from UTC. @@ -86,7 +89,7 @@ # Fix local copy of time tuple ltv = list(_fix_none_fields(tv)) - if ltv[0] < MINYEAR or ltv[0] > MAXYEAR: + if ltv[0] < MINYEAR + 1 or ltv[0] > MAXYEAR - 1: return tv # Unable to fix timestamp _tz_from = _tz_to_tzinfo(tz_from) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2009-01-06 23:45:59
|
Revision: 1478 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1478&view=rev Author: psha Date: 2009-01-06 23:45:51 +0000 (Tue, 06 Jan 2009) Log Message: ----------- Run tests for different timezones (MSK, PST, VOST, UTC) Modified Paths: -------------- trunk/zsi/test/test_TCtimes.py Modified: trunk/zsi/test/test_TCtimes.py =================================================================== --- trunk/zsi/test/test_TCtimes.py 2008-12-12 14:24:40 UTC (rev 1477) +++ trunk/zsi/test/test_TCtimes.py 2009-01-06 23:45:51 UTC (rev 1478) @@ -1,11 +1,13 @@ #!/usr/bin/env python -import unittest, sys, tests_good, tests_bad, time +import unittest, sys, tests_good, tests_bad, time, os from ZSI import * try: import cStringIO as StringIO except ImportError: import StringIO +os.environ['TZ'] = 'Europe/Moscow' +time.tzset() class TestCase(unittest.TestCase): '''Examples from "Definitive XML Schema, Priscilla Walmsley, p237-246 @@ -18,23 +20,37 @@ '%s with local offset(%s): expecting "%s" got "%s"' %( msg, data, correct, stamp)) - def check_datetime_timezone(self): + def _wrap_timezone(self, f, *a, **kw): + oldtz = os.environ.get('TZ', 'UTC') + for tz in ['Europe/Moscow', 'Antarctica/Vostok', 'America/Los_Angeles', 'UTC']: + try: + os.environ['TZ'] = tz + time.tzset() + f(*a, **kw) + finally: + os.environ['TZ'] = oldtz + time.tzset() + + def _check_datetime_timezone(self): # UTC with local timezone offset # Base example from http://www.w3.org/TR/xmlschema11-2/#dateTime-lexical-mapping correct = "2002-10-10T17:00:00Z" for t in ['2002-10-10T12:00:00-05:00', '2002-10-10T19:00:00+02:00', '2002-10-10T17:00:00+00:00', '2002-10-10T17:00:00Z']: self._check_data2data(TC.gDateTime(), t, correct, 'dateTime') + check_datetime_timezone = lambda s: s._wrap_timezone(s._check_datetime_timezone) - def check_time_timezone(self): + def _check_time_timezone(self): correct = "17:30:00Z" for t in ['12:30:00-05:00', '19:30:00+02:00', '17:30:00+00:00']: self._check_data2data(TC.gTime(), t, correct, 'time') + check_time_timezone = lambda s: s._wrap_timezone(s._check_time_timezone) - def check_date_timezone(self): + def _check_date_timezone(self): correct = "2002-10-10" for t in ['2002-10-10-05:00', '2002-10-10+02:00', '2002-10-10+00:00', '2002-10-10Z']: self._check_data2data(TC.gDate(), t, correct, 'date') + check_date_timezone = lambda s: s._wrap_timezone(s._check_date_timezone) def check_valid_dateTime(self): typecode = TC.gDateTime() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |