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: <rs...@us...> - 2007-07-31 14:23:16
|
Revision: 1410
http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1410&view=rev
Author: rsalz
Date: 2007-07-31 07:23:19 -0700 (Tue, 31 Jul 2007)
Log Message:
-----------
Add Chris Hobb's cookbook.
Thanks Chris!
Modified Paths:
--------------
trunk/pywebsvcs.sourceforge.net/index.html
Added Paths:
-----------
trunk/pywebsvcs.sourceforge.net/cookbook.pdf
Added: trunk/pywebsvcs.sourceforge.net/cookbook.pdf
===================================================================
--- trunk/pywebsvcs.sourceforge.net/cookbook.pdf (rev 0)
+++ trunk/pywebsvcs.sourceforge.net/cookbook.pdf 2007-07-31 14:23:19 UTC (rev 1410)
@@ -0,0 +1,2156 @@
+%PDF-1.4
+5 0 obj
+<< /S /GoTo /D (chapter.1) >>
+endobj
+8 0 obj
+(Introduction)
+endobj
+9 0 obj
+<< /S /GoTo /D (section.1.1) >>
+endobj
+12 0 obj
+(What is ZSI?)
+endobj
+13 0 obj
+<< /S /GoTo /D (section.1.2) >>
+endobj
+16 0 obj
+(Version)
+endobj
+17 0 obj
+<< /S /GoTo /D (section.1.3) >>
+endobj
+20 0 obj
+(Context)
+endobj
+21 0 obj
+<< /S /GoTo /D (section.1.4) >>
+endobj
+24 0 obj
+(Other Documentation)
+endobj
+25 0 obj
+<< /S /GoTo /D (chapter.2) >>
+endobj
+28 0 obj
+(Installation)
+endobj
+29 0 obj
+<< /S /GoTo /D (chapter.3) >>
+endobj
+32 0 obj
+(Code Generation)
+endobj
+33 0 obj
+<< /S /GoTo /D (section.3.1) >>
+endobj
+36 0 obj
+(Generating the Consumer \(Client\))
+endobj
+37 0 obj
+<< /S /GoTo /D (section.3.2) >>
+endobj
+40 0 obj
+(Generating the Server)
+endobj
+41 0 obj
+<< /S /GoTo /D (chapter.4) >>
+endobj
+44 0 obj
+(Examples)
+endobj
+45 0 obj
+<< /S /GoTo /D (section.4.1) >>
+endobj
+48 0 obj
+(Creating a Simple Client)
+endobj
+49 0 obj
+<< /S /GoTo /D (section.4.2) >>
+endobj
+52 0 obj
+(Creating a Slightly More Sophisticated Client)
+endobj
+53 0 obj
+<< /S /GoTo /D (section.4.3) >>
+endobj
+56 0 obj
+(Creating a Simple Server)
+endobj
+57 0 obj
+<< /S /GoTo /D (chapter.5) >>
+endobj
+60 0 obj
+(Gotchas and Tips)
+endobj
+61 0 obj
+<< /S /GoTo /D (section.5.1) >>
+endobj
+64 0 obj
+(Tracing)
+endobj
+65 0 obj
+<< /S /GoTo /D (section.5.2) >>
+endobj
+68 0 obj
+(DateTime Fields)
+endobj
+69 0 obj
+<< /S /GoTo /D (section.5.3) >>
+endobj
+72 0 obj
+(Duration Fields)
+endobj
+73 0 obj
+<< /S /GoTo /D (section.5.4) >>
+endobj
+76 0 obj
+(Exceptions)
+endobj
+77 0 obj
+<< /S /GoTo /D [78 0 R /Fit ] >>
+endobj
+81 0 obj <<
+/Length 352
+/Filter /FlateDecode
+>>
+stream
+xڍ\x92\xC9n\xC2@\x86\xEFy
+Aj\x8C\xED\xCFd\x8E\xAD\xBAn\xB4\xE9\xA5U(\x84E"@E\xEA\xDB7\xA1)\xA2\x8B\xE6\xCB\xFE\xC7\xFE\xFCg\xA8<^\xC0\x93CR1\x90\xAD#\x82y\x99~\x88\xF8X\xB6F\xCA\xEF\x85B,\xC1\xA0U\xEB v
+\x97}:\xAAs\xB56Һl\x81\xD0z\xAD\x8Bݸ\xACnOw\x8E\x89\xC1p\xCDp[D\xE3Ɲ\xE9\
+6 z\xA3\\xC9n\xD2hp/L(0\xA43\xF6\xE8+hp\x98\x98\xA0\x90N_{\xD7\xD3C_\xB47\xD9d\xF9\xB4\x8BR/\xED{\xEA\xE5\xD9bS\xAC\x8A\xF9G\x93{\xCC\xF7\xF9d\x97-\xFAo\xE9(\xBAKO\x83\x9DC\xB5\xAA`\xAB\xC0%\xFEϥ\xB5\xB5\x8Fj/-{\xBBf_˔\xDE\xC5݆\xED.b\xD1'\xBE\xD9\xC58\xF4dXT\xF2\xAE\xDE\xE5y\xBF\xDC\xCC\xE0\x97\xA7\xE19k\xD9\xD6A\xC7\xC1\xFD\xA1+>\xD9\xC9T\xA5B\xB0\xD6`\xA2\x96\xC1\xF8\x9D\xE7P#<敛\x87\xE5~YlF:')\xD3\xC8N\x81% 9\xF3\x9Biq\xAB\x8D;\xE24\xA2\xDA\xC0\xB6\xB2
+f\xF4\xBE:\xFE?CWM D\xFE\x821ߟ돯\xFD3\xAC\xA7Bendstream
+endobj
+78 0 obj <<
+/Type /Page
+/Contents 81 0 R
+/Resources 80 0 R
+/MediaBox [0 0 612 792]
+/Parent 87 0 R
+>> endobj
+79 0 obj <<
+/Type /XObject
+/Subtype /Form
+/FormType 1
+/PTEX.FileName (/home/cwlh/texmf/tex/latex/nortel_logo_blue.pdf)
+/PTEX.PageNumber 1
+/PTEX.InfoDict 88 0 R
+/Matrix [1.00000000 0.00000000 0.00000000 1.00000000 0.00000000 0.00000000]
+/BBox [0.00000000 0.00000000 303.00000000 73.00000000]
+/Resources <<
+/ProcSet [ /PDF ]
+/ColorSpace <<
+/R8 89 0 R
+>>/ExtGState <<
+/R7 90 0 R
+>>>>
+/Length 91 0 R
+/Filter /FlateDecode
+>>
+stream
+x\x9Cm\x95anc7\x84\xFF\xFB\xBA@TQ")\xE9\xED\xB4\xBB\x80S\xA0\xC8\xFD\x81~#;\xC9\xC2\xDE
+\xB0o,\x913\xE4\x90\xEF\xBFҪ\x95\xA6\xBF\xC7\xF3\xFA~\xF9\xE3\xAFY\xFE\xF9\xE0\xB1\xCA\xF5\xE3b\xE5\xE3\xFA/\xFF\xFF\xBC\x98\x8D\xA8\xD1K\xAB\x8B\xE7\xFBŚ\xAD\x9A \xAD\xD7\xE1^\x96\x8F\x9Aˋ\xB7Y=w\x99nu\xB6Q\x86\xF5:\xC3\xCB\xF52\xF7\xA8\xEE\xBBX\xAEڦ\x97\xBD\xB2\xFAZeg\xEF^̼W"ز\x9A\xADs\xC3:\xC8^eG\x9D\xBD\xCFr#\xEB\x8AjYވjm\x84\x93\x9F\xDEV\xED\x8D\eAt\xB7,<\x96ϩ\xBC\x95p\xE6\xB5E[%\xFB\xAA\xFA\xE1m\x8BEG\xC1F\xC1\xB6\x92Y\xFB\x9C\x83\xE9\xB3Z\xDFex\xE5r\x96ٽ\xFAXų\x86\xD9,s\xA1\xB5GI\x887\xAA\x80\xA4>J\xCEVbK\xCE\xE7\xD8u\xA7\x95Nmr\x88Sڮ\xA3/\xB4r$x\xAEƍѐ3x'U\xF32\xA3\xE64e
+\x9D\x80\xBEr\xC6\xDC5]1\xB3\xDA\xDEp\x99GV\x8FQ\xBBD
+h\x84p\x92\x8F5\xCE5*ǡ:c\xD6i\x8168S\xE3\xEBe%Z\x9D\xA9\xA2\xDF.9"G\x87-55Њ/;Wͣ\x8C$r\x88\xE4\xB2<2\x9CJ\xE9\xC6&\x827\xD99t\xBE\xA9\xD4Y\x82\xF77H\xD2\xF2\xD8w\xF2\x9BL\xE2\xA8w\xB5d\x90)&\xEE$''5}T\xA2\xC3r\xC3FmK\xEE.r\xFFj\xD0\xBA#\xDCN\x8D\xF7)\xA9u;\xB6BiBcÒ6\xDBPI\x8EL\xA4\xF0\xF8m\xAFw5\xCBF\xE7*\xAC"\xEB\xF4\xA4\xD3%'\xFDrVǍ\x9B\xBEV \xB0:)\xBD\xE3Ů\xFCb\xF4J\xBAà\xC4̆\xE1\xB9@\x85ȭBt
+\xE7G\xBEYr\xFAh*\xAE\x924y\xA1x\x90\xBB<\xCF\xE3\xF5\xF274\xD1
+\xE1\xB1p\xF6ֈ> |
|
From: <bov...@us...> - 2007-07-17 22:40:53
|
Revision: 1409
http://svn.sourceforge.net/pywebsvcs/?rev=1409&view=rev
Author: boverhof
Date: 2007-07-17 15:40:51 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
M test/test_t1.py
M ZSI/TC.py
FIX BUG [ 1724481 ] Error handling of enum serialization broken
Modified Paths:
--------------
trunk/zsi/ZSI/TC.py
trunk/zsi/test/test_t1.py
Modified: trunk/zsi/ZSI/TC.py
===================================================================
--- trunk/zsi/ZSI/TC.py 2007-07-17 22:26:07 UTC (rev 1408)
+++ trunk/zsi/ZSI/TC.py 2007-07-17 22:40:51 UTC (rev 1409)
@@ -917,7 +917,7 @@
def serialize(self, elt, sw, pyobj, name=None, orig=None, **kw):
if pyobj not in self.choices:
raise EvaluateException('Value not in enumeration list',
- ps.Backtrace(elt))
+ sw.Backtrace(elt))
String.serialize(self, elt, sw, pyobj, name=name, orig=orig, **kw)
Modified: trunk/zsi/test/test_t1.py
===================================================================
--- trunk/zsi/test/test_t1.py 2007-07-17 22:26:07 UTC (rev 1408)
+++ trunk/zsi/test/test_t1.py 2007-07-17 22:40:51 UTC (rev 1409)
@@ -27,6 +27,12 @@
self.goodTests.sort(lambda a,b: cmp(a[0], b[0]))
self.badTests.sort(lambda a,b: cmp(a[0], b[0]))
+ def check_bug1724481(self):
+ # [ 1724481 ] Error handling of enum serialization broken"
+ enum = TC.Enumeration(['Red', 'Blue', 'Green'], 'color')
+ sw = SoapWriter()
+ self.assertRaises(EvaluateException, sw.serialize,'ddd', enum)
+
def checkt1(self):
for key,val in self.badTests:
print "\n", "." * 60, key
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-17 22:40:45
|
Revision: 1408
http://svn.sourceforge.net/pywebsvcs/?rev=1408&view=rev
Author: boverhof
Date: 2007-07-17 15:26:07 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
M test/wsdl2py/config.txt
A test/wsdl2py/wsdl/vim.wsdl
A test/wsdl2py/test_VIM.py
M ZSI/TCcompound.py
-- FIX and UNITTEST FOR BUG [ 1755740 ] Multiple calls to the same method
Modified Paths:
--------------
trunk/zsi/ZSI/TCcompound.py
trunk/zsi/test/wsdl2py/config.txt
Added Paths:
-----------
trunk/zsi/test/wsdl2py/test_VIM.py
trunk/zsi/test/wsdl2py/wsdl/vim.wsdl
Modified: trunk/zsi/ZSI/TCcompound.py
===================================================================
--- trunk/zsi/ZSI/TCcompound.py 2007-07-11 00:09:00 UTC (rev 1407)
+++ trunk/zsi/ZSI/TCcompound.py 2007-07-17 22:26:07 UTC (rev 1408)
@@ -19,6 +19,7 @@
from ZSI.wstools.Utility import SplitQName
from ZSI.wstools.logging import getLogger as _GetLogger
import re, types
+from copy import copy as _copy
_find_arrayoffset = lambda E: E.getAttributeNS(SOAP.ENC, "offset")
_find_arrayposition = lambda E: E.getAttributeNS(SOAP.ENC, "position")
@@ -74,12 +75,14 @@
'failed to serialize substitute %s for %s, not derivation: %s' %
(sub, typecode, sw.Backtrace(elt),))
- # Make our substitution type match the elements facets
+ # Make our substitution type match the elements facets,
+ # since typecode is created for a single existing pyobj
+ # some facets are irrelevant.
+ sub = _copy(sub)
sub.nspname = typecode.nspname
sub.pname = typecode.pname
sub.aname = typecode.aname
- sub.minOccurs = 1
- sub.maxOccurs = 1
+ sub.minOccurs = sub.maxOccurs = 1
return sub
Modified: trunk/zsi/test/wsdl2py/config.txt
===================================================================
--- trunk/zsi/test/wsdl2py/config.txt 2007-07-11 00:09:00 UTC (rev 1407)
+++ trunk/zsi/test/wsdl2py/config.txt 2007-07-17 22:26:07 UTC (rev 1408)
@@ -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
+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
[doc_literal_broke]
document = True
@@ -180,5 +180,6 @@
test_NVOAdmin = wsdl/nvo-admin.wsdl
test_Clearspace = http://eval.jivesoftware.com/clearspace/rpc/soap/BlogService?wsdl
+test_VIM = wsdl/vim.wsdl
Added: trunk/zsi/test/wsdl2py/test_VIM.py
===================================================================
--- trunk/zsi/test/wsdl2py/test_VIM.py (rev 0)
+++ trunk/zsi/test/wsdl2py/test_VIM.py 2007-07-17 22:26:07 UTC (rev 1408)
@@ -0,0 +1,115 @@
+#!/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: wsdl/vim.wsdl
+"""
+
+# General targets
+def dispatch():
+ """Run all dispatch tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(VIMTestCase, 'test_dispatch'))
+ return suite
+
+def local():
+ """Run all local tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(VIMTestCase, 'test_local'))
+ return suite
+
+def net():
+ """Run all network tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(VIMTestCase, 'test_net'))
+ return suite
+
+def all():
+ """Run all tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(VIMTestCase, 'test_'))
+ return suite
+
+
+class VIMTestCase(ServiceTestCase):
+ name = "test_VIM"
+ client_file_name = "VIM_client.py"
+ types_file_name = "VIM_types.py"
+ server_file_name = "VIM_server.py"
+
+ def __init__(self, methodName):
+ ServiceTestCase.__init__(self, methodName)
+ self.wsdl2py_args.append('--lazy')
+ self.wsdl2py_args.append('-b')
+
+ def test_local_substitute_SessionManager(self):
+ # BUG [ 1755740 ] Multiple calls to the same method
+ MSG = """<?xml version="1.0" encoding="UTF-8"?>
+<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<soapenv:Body>
+<RetrieveServiceContentResponse xmlns="urn:vim2">
+ <returnval>
+ <rootFolder type="Folder">group-d1</rootFolder>
+ <propertyCollector type="PropertyCollector">propertyCollector</propertyCollector>
+ <about>
+ <name>VMware VirtualCenter</name>
+ <fullName>VMware VirtualCenter 2.0.1 build-32042</fullName>
+ <vendor>VMware, Inc.</vendor>
+ <version>2.0.1</version>
+ <build>32042</build>
+ <localeVersion>INTL</localeVersion>
+ <localeBuild>000</localeBuild>
+ <osType>win32-x86</osType>
+ <productLineId>vpx</productLineId>
+ <apiType>VirtualCenter</apiType>
+ <apiVersion>2.0.0</apiVersion>
+ </about>
+ <setting type="OptionManager">VpxSettings</setting>
+ <userDirectory type="UserDirectory">UserDirectory</userDirectory>
+ <sessionManager type="SessionManager">SessionManager</sessionManager>
+ <authorizationManager type="AuthorizationManager">AuthorizationManager</authorizationManager>
+ <perfManager type="PerformanceManager">PerfMgr</perfManager>
+ <scheduledTaskManager type="ScheduledTaskManager">ScheduledTaskManager</scheduledTaskManager>
+ <alarmManager type="AlarmManager">AlarmManager</alarmManager>
+ <eventManager type="EventManager">EventManager</eventManager>
+ <taskManager type="TaskManager">TaskManager</taskManager>
+ <customizationSpecManager type="CustomizationSpecManager">CustomizationSpecManager</customizationSpecManager>
+ <customFieldsManager type="CustomFieldsManager">CustomFieldsManager</customFieldsManager>
+ <diagnosticManager type="DiagnosticManager">DiagMgr</diagnosticManager>
+ <licenseManager type="LicenseManager">LicenseManager</licenseManager>
+ <searchIndex type="SearchIndex">SearchIndex</searchIndex>
+ </returnval>
+</RetrieveServiceContentResponse>
+</soapenv:Body>
+</soapenv:Envelope>"""
+
+ # Parse it out
+ ps = ParsedSoap(MSG)
+ pyobj = ps.Parse( self.client_module.RetrieveServiceContentResponseMsg.typecode )
+ sessionMgr = pyobj.Returnval.SessionManager
+
+ # Serialize SessionManager in different context
+ msg = self.client_module.LogoutRequestMsg()
+ msg._this = sessionMgr
+ SoapWriter().serialize(msg)
+
+ # Parse it out: was failing
+ # ZSI.EvaluateException: Element "__this" missing from complexType
+ # [Element trace: /soapenv:Envelope/soapenv:Body/RetrieveServiceContentResponse/returnval]
+ ps = ParsedSoap(MSG)
+ pyobj = ps.Parse( self.client_module.RetrieveServiceContentResponseMsg.typecode )
+
+
+if __name__ == "__main__" :
+ main()
+
Added: trunk/zsi/test/wsdl2py/wsdl/vim.wsdl
===================================================================
--- trunk/zsi/test/wsdl2py/wsdl/vim.wsdl (rev 0)
+++ trunk/zsi/test/wsdl2py/wsdl/vim.wsdl 2007-07-17 22:26:07 UTC (rev 1408)
@@ -0,0 +1,22098 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<definitions name="VIM" targetNamespace="urn:vim2"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:vim2="urn:vim2"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+>
+ <types>
+ <schema
+ targetNamespace="urn:vim2"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:vim2="urn:vim2"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ >
+ <complexType name="DynamicArray">
+ <sequence>
+ <element name="dynamicType" type="xsd:string" minOccurs="0" />
+ <element name="val" type="xsd:anyType" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="DynamicData">
+ <sequence>
+ <element name="dynamicType" type="xsd:string" minOccurs="0" />
+ <element name="dynamicProperty" type="vim2:DynamicProperty" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="DynamicProperty">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="val" type="xsd:anyType" />
+ </sequence>
+ </complexType>
+ <complexType name="ArrayOfDynamicProperty">
+ <sequence>
+ <element name="DynamicProperty" type="vim2:DynamicProperty" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="HostCommunication">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="HostCommunicationFault" type="vim2:HostCommunication"/>
+ <complexType name="HostNotConnected">
+ <complexContent>
+ <extension base="vim2:HostCommunication">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="HostNotConnectedFault" type="vim2:HostNotConnected"/>
+ <complexType name="HostNotReachable">
+ <complexContent>
+ <extension base="vim2:HostCommunication">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="HostNotReachableFault" type="vim2:HostNotReachable"/>
+ <complexType name="InvalidArgument">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ <element name="invalidProperty" type="xsd:string" minOccurs="0" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="InvalidArgumentFault" type="vim2:InvalidArgument"/>
+ <complexType name="InvalidRequest">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="InvalidRequestFault" type="vim2:InvalidRequest"/>
+ <complexType name="InvalidType">
+ <complexContent>
+ <extension base="vim2:InvalidRequest">
+ <sequence>
+ <element name="argument" type="xsd:string" minOccurs="0" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="InvalidTypeFault" type="vim2:InvalidType"/>
+ <complexType name="ManagedObjectNotFound">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ <element name="obj" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="ManagedObjectNotFoundFault" type="vim2:ManagedObjectNotFound"/>
+ <complexType name="MethodNotFound">
+ <complexContent>
+ <extension base="vim2:InvalidRequest">
+ <sequence>
+ <element name="receiver" type="vim2:ManagedObjectReference" />
+ <element name="method" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="MethodNotFoundFault" type="vim2:MethodNotFound"/>
+ <complexType name="NotEnoughLicenses">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="NotEnoughLicensesFault" type="vim2:NotEnoughLicenses"/>
+ <complexType name="NotImplemented">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="NotImplementedFault" type="vim2:NotImplemented"/>
+ <complexType name="NotSupported">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="NotSupportedFault" type="vim2:NotSupported"/>
+ <complexType name="RequestCanceled">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="RequestCanceledFault" type="vim2:RequestCanceled"/>
+ <complexType name="SecurityError">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="SecurityErrorFault" type="vim2:SecurityError"/>
+ <complexType name="SystemError">
+ <complexContent>
+ <extension base="vim2:RuntimeFault">
+ <sequence>
+ <element name="reason" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="SystemErrorFault" type="vim2:SystemError"/>
+ <complexType name="InvalidCollectorVersion">
+ <complexContent>
+ <extension base="vim2:MethodFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="InvalidCollectorVersionFault" type="vim2:InvalidCollectorVersion"/>
+ <complexType name="InvalidProperty">
+ <complexContent>
+ <extension base="vim2:MethodFault">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="InvalidPropertyFault" type="vim2:InvalidProperty"/>
+ <complexType name="PropertyFilterSpec">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="propSet" type="vim2:PropertySpec" maxOccurs="unbounded" />
+ <element name="objectSet" type="vim2:ObjectSpec" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfPropertyFilterSpec">
+ <sequence>
+ <element name="PropertyFilterSpec" type="vim2:PropertyFilterSpec" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="PropertySpec">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="type" type="xsd:string" />
+ <element name="all" type="xsd:boolean" minOccurs="0" />
+ <element name="pathSet" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfPropertySpec">
+ <sequence>
+ <element name="PropertySpec" type="vim2:PropertySpec" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="ObjectSpec">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="obj" type="vim2:ManagedObjectReference" />
+ <element name="skip" type="xsd:boolean" minOccurs="0" />
+ <element name="selectSet" type="vim2:SelectionSpec" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfObjectSpec">
+ <sequence>
+ <element name="ObjectSpec" type="vim2:ObjectSpec" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="SelectionSpec">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="name" type="xsd:string" minOccurs="0" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfSelectionSpec">
+ <sequence>
+ <element name="SelectionSpec" type="vim2:SelectionSpec" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="TraversalSpec">
+ <complexContent>
+ <extension base="vim2:SelectionSpec">
+ <sequence>
+ <element name="type" type="xsd:string" />
+ <element name="path" type="xsd:string" />
+ <element name="skip" type="xsd:boolean" minOccurs="0" />
+ <element name="selectSet" type="vim2:SelectionSpec" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="DestroyPropertyFilter">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="DestroyPropertyFilterResponse">
+ <complexType />
+ </element>
+ <complexType name="ObjectContent">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="obj" type="vim2:ManagedObjectReference" />
+ <element name="propSet" type="vim2:DynamicProperty" minOccurs="0" maxOccurs="unbounded" />
+ <element name="missingSet" type="vim2:MissingProperty" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfObjectContent">
+ <sequence>
+ <element name="ObjectContent" type="vim2:ObjectContent" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="UpdateSet">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="version" type="xsd:string" />
+ <element name="filterSet" type="vim2:PropertyFilterUpdate" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="PropertyFilterUpdate">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="filter" type="vim2:ManagedObjectReference" />
+ <element name="objectSet" type="vim2:ObjectUpdate" minOccurs="0" maxOccurs="unbounded" />
+ <element name="missingSet" type="vim2:MissingObject" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfPropertyFilterUpdate">
+ <sequence>
+ <element name="PropertyFilterUpdate" type="vim2:PropertyFilterUpdate" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <simpleType name="ObjectUpdateKind">
+ <restriction base="xsd:string">
+ <enumeration value="modify" />
+ <enumeration value="enter" />
+ <enumeration value="leave" />
+ </restriction>
+ </simpleType>
+ <complexType name="ObjectUpdate">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="kind" type="vim2:ObjectUpdateKind" />
+ <element name="obj" type="vim2:ManagedObjectReference" />
+ <element name="changeSet" type="vim2:PropertyChange" minOccurs="0" maxOccurs="unbounded" />
+ <element name="missingSet" type="vim2:MissingProperty" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfObjectUpdate">
+ <sequence>
+ <element name="ObjectUpdate" type="vim2:ObjectUpdate" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <simpleType name="PropertyChangeOp">
+ <restriction base="xsd:string">
+ <enumeration value="add" />
+ <enumeration value="remove" />
+ <enumeration value="assign" />
+ <enumeration value="indirectRemove" />
+ </restriction>
+ </simpleType>
+ <complexType name="PropertyChange">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="op" type="vim2:PropertyChangeOp" />
+ <element name="val" type="xsd:anyType" minOccurs="0" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfPropertyChange">
+ <sequence>
+ <element name="PropertyChange" type="vim2:PropertyChange" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="MissingProperty">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="path" type="xsd:string" />
+ <element name="fault" type="vim2:LocalizedMethodFault" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfMissingProperty">
+ <sequence>
+ <element name="MissingProperty" type="vim2:MissingProperty" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="MissingObject">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="obj" type="vim2:ManagedObjectReference" />
+ <element name="fault" type="vim2:LocalizedMethodFault" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfMissingObject">
+ <sequence>
+ <element name="MissingObject" type="vim2:MissingObject" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <element name="CreateFilter">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="spec" type="vim2:PropertyFilterSpec" />
+ <element name="partialUpdates" type="xsd:boolean" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CreateFilterResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RetrieveProperties">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="specSet" type="vim2:PropertyFilterSpec" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RetrievePropertiesResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:ObjectContent" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CheckForUpdates">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="version" type="xsd:string" minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CheckForUpdatesResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:UpdateSet" minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="WaitForUpdates">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="version" type="xsd:string" minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="WaitForUpdatesResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:UpdateSet" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CancelWaitForUpdates">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CancelWaitForUpdatesResponse">
+ <complexType />
+ </element>
+ <complexType name="LocalizedMethodFault">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="fault" type="vim2:MethodFault" />
+ <element name="localizedMessage" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="MethodFault">
+ <sequence>
+ <element name="dynamicType" type="xsd:string" minOccurs="0" />
+ <element name="dynamicProperty" type="vim2:DynamicProperty" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <element name="MethodFaultFault" type="vim2:MethodFault"/>
+ <complexType name="RuntimeFault">
+ <complexContent>
+ <extension base="vim2:MethodFault">
+ <sequence>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="RuntimeFaultFault" type="vim2:RuntimeFault"/>
+ <complexType name="AboutInfo">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="fullName" type="xsd:string" />
+ <element name="vendor" type="xsd:string" />
+ <element name="version" type="xsd:string" />
+ <element name="build" type="xsd:string" />
+ <element name="localeVersion" type="xsd:string" minOccurs="0" />
+ <element name="localeBuild" type="xsd:string" minOccurs="0" />
+ <element name="osType" type="xsd:string" />
+ <element name="productLineId" type="xsd:string" />
+ <element name="apiType" type="xsd:string" />
+ <element name="apiVersion" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="AuthorizationDescription">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="privilege" type="vim2:ElementDescription" maxOccurs="unbounded" />
+ <element name="privilegeGroup" type="vim2:ElementDescription" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="Permission">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="entity" type="vim2:ManagedObjectReference" minOccurs="0" />
+ <element name="principal" type="xsd:string" />
+ <element name="group" type="xsd:boolean" />
+ <element name="roleId" type="xsd:int" />
+ <element name="propagate" type="xsd:boolean" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfPermission">
+ <sequence>
+ <element name="Permission" type="vim2:Permission" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="AuthorizationRole">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="roleId" type="xsd:int" />
+ <element name="system" type="xsd:boolean" />
+ <element name="name" type="xsd:string" />
+ <element name="info" type="vim2:Description" />
+ <element name="privilege" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfAuthorizationRole">
+ <sequence>
+ <element name="AuthorizationRole" type="vim2:AuthorizationRole" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="AuthorizationPrivilege">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="privId" type="xsd:string" />
+ <element name="onParent" type="xsd:boolean" />
+ <element name="name" type="xsd:string" />
+ <element name="privGroupName" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfAuthorizationPrivilege">
+ <sequence>
+ <element name="AuthorizationPrivilege" type="vim2:AuthorizationPrivilege" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <element name="AddAuthorizationRole">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="name" type="xsd:string" />
+ <element name="privIds" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="AddAuthorizationRoleResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="xsd:int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RemoveAuthorizationRole">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="roleId" type="xsd:int" />
+ <element name="failIfUsed" type="xsd:boolean" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RemoveAuthorizationRoleResponse">
+ <complexType />
+ </element>
+ <element name="UpdateAuthorizationRole">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="roleId" type="xsd:int" />
+ <element name="newName" type="xsd:string" />
+ <element name="privIds" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="UpdateAuthorizationRoleResponse">
+ <complexType />
+ </element>
+ <element name="MergePermissions">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="srcRoleId" type="xsd:int" />
+ <element name="dstRoleId" type="xsd:int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="MergePermissionsResponse">
+ <complexType />
+ </element>
+ <element name="RetrieveRolePermissions">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="roleId" type="xsd:int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RetrieveRolePermissionsResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:Permission" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RetrieveEntityPermissions">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="entity" type="vim2:ManagedObjectReference" />
+ <element name="inherited" type="xsd:boolean" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RetrieveEntityPermissionsResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:Permission" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RetrieveAllPermissions">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RetrieveAllPermissionsResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:Permission" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="SetEntityPermissions">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="entity" type="vim2:ManagedObjectReference" />
+ <element name="permission" type="vim2:Permission" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="SetEntityPermissionsResponse">
+ <complexType />
+ </element>
+ <element name="ResetEntityPermissions">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="entity" type="vim2:ManagedObjectReference" />
+ <element name="permission" type="vim2:Permission" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="ResetEntityPermissionsResponse">
+ <complexType />
+ </element>
+ <element name="RemoveEntityPermission">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="entity" type="vim2:ManagedObjectReference" />
+ <element name="user" type="xsd:string" />
+ <element name="isGroup" type="xsd:boolean" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RemoveEntityPermissionResponse">
+ <complexType />
+ </element>
+ <complexType name="Capability">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="provisioningSupported" type="xsd:boolean" />
+ <element name="multiHostSupported" type="xsd:boolean" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ClusterComputeResourceSummary">
+ <complexContent>
+ <extension base="vim2:ComputeResourceSummary">
+ <sequence>
+ <element name="currentFailoverLevel" type="xsd:int" />
+ <element name="numVmotions" type="xsd:int" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="ReconfigureCluster_Task">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="spec" type="vim2:ClusterConfigSpec" />
+ <element name="modify" type="xsd:boolean" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="ReconfigureCluster_TaskResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="ApplyRecommendation">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="key" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="ApplyRecommendationResponse">
+ <complexType />
+ </element>
+ <element name="RecommendHostsForVm">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="vm" type="vim2:ManagedObjectReference" />
+ <element name="pool" type="vim2:ManagedObjectReference" minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RecommendHostsForVmResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:ClusterHostRecommendation" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="AddHost_Task">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="spec" type="vim2:HostConnectSpec" />
+ <element name="asConnected" type="xsd:boolean" />
+ <element name="resourcePool" type="vim2:ManagedObjectReference" minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="AddHost_TaskResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="MoveInto_Task">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="host" type="vim2:ManagedObjectReference" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="MoveInto_TaskResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="MoveHostInto_Task">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="host" type="vim2:ManagedObjectReference" />
+ <element name="resourcePool" type="vim2:ManagedObjectReference" minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="MoveHostInto_TaskResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <complexType name="ComputeResourceSummary">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="totalCpu" type="xsd:int" />
+ <element name="totalMemory" type="xsd:long" />
+ <element name="numCpuCores" type="xsd:short" />
+ <element name="numCpuThreads" type="xsd:short" />
+ <element name="effectiveCpu" type="xsd:int" />
+ <element name="effectiveMemory" type="xsd:long" />
+ <element name="numHosts" type="xsd:int" />
+ <element name="numEffectiveHosts" type="xsd:int" />
+ <element name="overallStatus" type="vim2:ManagedEntityStatus" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="CustomFieldDef">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="key" type="xsd:int" />
+ <element name="name" type="xsd:string" />
+ <element name="type" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfCustomFieldDef">
+ <sequence>
+ <element name="CustomFieldDef" type="vim2:CustomFieldDef" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="CustomFieldValue">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="key" type="xsd:int" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfCustomFieldValue">
+ <sequence>
+ <element name="CustomFieldValue" type="vim2:CustomFieldValue" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="CustomFieldStringValue">
+ <complexContent>
+ <extension base="vim2:CustomFieldValue">
+ <sequence>
+ <element name="value" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="AddCustomFieldDef">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="AddCustomFieldDefResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:CustomFieldDef" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RemoveCustomFieldDef">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="key" type="xsd:int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RemoveCustomFieldDefResponse">
+ <complexType />
+ </element>
+ <element name="RenameCustomFieldDef">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="key" type="xsd:int" />
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RenameCustomFieldDefResponse">
+ <complexType />
+ </element>
+ <element name="SetField">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="entity" type="vim2:ManagedObjectReference" />
+ <element name="key" type="xsd:int" />
+ <element name="value" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="SetFieldResponse">
+ <complexType />
+ </element>
+ <element name="DoesCustomizationSpecExist">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="DoesCustomizationSpecExistResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="xsd:boolean" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="GetCustomizationSpec">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="GetCustomizationSpecResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:CustomizationSpecItem" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CreateCustomizationSpec">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="item" type="vim2:CustomizationSpecItem" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CreateCustomizationSpecResponse">
+ <complexType />
+ </element>
+ <element name="OverwriteCustomizationSpec">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="item" type="vim2:CustomizationSpecItem" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="OverwriteCustomizationSpecResponse">
+ <complexType />
+ </element>
+ <element name="DeleteCustomizationSpec">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="DeleteCustomizationSpecResponse">
+ <complexType />
+ </element>
+ <element name="DuplicateCustomizationSpec">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="name" type="xsd:string" />
+ <element name="newName" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="DuplicateCustomizationSpecResponse">
+ <complexType />
+ </element>
+ <element name="RenameCustomizationSpec">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="name" type="xsd:string" />
+ <element name="newName" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RenameCustomizationSpecResponse">
+ <complexType />
+ </element>
+ <element name="CustomizationSpecItemToXml">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="item" type="vim2:CustomizationSpecItem" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CustomizationSpecItemToXmlResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="XmlToCustomizationSpecItem">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="specItemXml" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="XmlToCustomizationSpecItemResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:CustomizationSpecItem" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CheckCustomizationResources">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="guestOs" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="CheckCustomizationResourcesResponse">
+ <complexType />
+ </element>
+ <complexType name="CustomizationSpecInfo">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="description" type="xsd:string" />
+ <element name="type" type="xsd:string" />
+ <element name="changeVersion" type="xsd:string" minOccurs="0" />
+ <element name="lastUpdateTime" type="xsd:dateTime" minOccurs="0" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfCustomizationSpecInfo">
+ <sequence>
+ <element name="CustomizationSpecInfo" type="vim2:CustomizationSpecInfo" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="CustomizationSpecItem">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="info" type="vim2:CustomizationSpecInfo" />
+ <element name="spec" type="vim2:CustomizationSpec" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="QueryConnectionInfo">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="hostname" type="xsd:string" />
+ <element name="port" type="xsd:int" />
+ <element name="username" type="xsd:string" />
+ <element name="password" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="QueryConnectionInfoResponse">
+ <complexType>
+ <sequence>
+ <element name="returnval" type="vim2:HostConnectInfo" />
+ </sequence>
+ </complexType>
+ </element>
+ <complexType name="DatastoreSummary">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="datastore" type="vim2:ManagedObjectReference" minOccurs="0" />
+ <element name="name" type="xsd:string" />
+ <element name="url" type="xsd:string" />
+ <element name="capacity" type="xsd:long" />
+ <element name="freeSpace" type="xsd:long" />
+ <element name="accessible" type="xsd:boolean" />
+ <element name="multipleHostAccess" type="xsd:boolean" minOccurs="0" />
+ <element name="type" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="DatastoreInfo">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="url" type="xsd:string" />
+ <element name="freeSpace" type="xsd:long" />
+ <element name="maxFileSize" type="xsd:long" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="DatastoreCapability">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="directoryHierarchySupported" type="xsd:boolean" />
+ <element name="rawDiskMappingsSupported" type="xsd:boolean" />
+ <element name="perFileThinProvisioningSupported" type="xsd:boolean" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="DatastoreHostMount">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="key" type="vim2:ManagedObjectReference" />
+ <element name="mountInfo" type="vim2:HostMountInfo" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ArrayOfDatastoreHostMount">
+ <sequence>
+ <element name="DatastoreHostMount" type="vim2:DatastoreHostMount" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <element name="RenameDatastore">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ <element name="newName" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RenameDatastoreResponse">
+ <complexType />
+ </element>
+ <element name="RefreshDatastore">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="RefreshDatastoreResponse">
+ <complexType />
+ </element>
+ <element name="DestroyDatastore">
+ <complexType>
+ <sequence>
+ <element name="_this" type="vim2:ManagedObjectReference" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="DestroyDatastoreResponse">
+ <complexType />
+ </element>
+ <complexType name="Description">
+ <complexContent>
+ <extension base="vim2:DynamicData">
+ <sequence>
+ <element name="label" type="xsd:string" />
+ <element name="summary" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <simpleType name="DiagnosticManagerLogCreator">
+ <restriction base="xsd:string">
+ <enumeration value="vpxd" />
+ <enumeration value="vpxa" />
+ <enumeration value="hostd" />
+ <enumeration value="serverd" />
+ <enumeration value="install" />
+ <enumeration value="vpxClient" />
+ </restriction>
+ </simpleType>
+ <simpleType name="DiagnosticManagerLogFormat">
+ <restriction base="xsd:string">
+ <enumeration value="plain" />
+ </restriction>
+ </simpleType>
+ <complexType name="DiagnosticManagerLogDescriptor">
+ ...
[truncated message content] |
|
From: <bov...@us...> - 2007-07-11 00:09:05
|
Revision: 1407
http://svn.sourceforge.net/pywebsvcs/?rev=1407&view=rev
Author: boverhof
Date: 2007-07-10 17:09:00 -0700 (Tue, 10 Jul 2007)
Log Message:
-----------
M test/wsdl2py/config.txt
A test/wsdl2py/test_Clearspace.py
M ZSI/generate/commands.py
M ZSI/generate/containers.py
-- throw warning if missing "import" in schema, this shows up with wsdl2py --debug
-- look for dependent schemas in WSDL types information item, if find it great if not throw SchemaError
-- added unittest for Clearspace BlogService using WSSE:Security UsernameToken profile, uses the public sandbox
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
trunk/zsi/ZSI/generate/containers.py
trunk/zsi/test/wsdl2py/config.txt
Added Paths:
-----------
trunk/zsi/test/wsdl2py/test_Clearspace.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-07-10 20:26:11 UTC (rev 1406)
+++ trunk/zsi/ZSI/generate/commands.py 2007-07-11 00:09:00 UTC (rev 1407)
@@ -150,10 +150,10 @@
if isinstance(wsdl, XMLSchema.XMLSchema):
wsdl.location = location
- return _wsdl2py(options, wsdl)
-
- files = _wsdl2py(options, wsdl)
- files.append(_wsdl2dispatch(options, wsdl))
+ files = _wsdl2py(options, wsdl)
+ else:
+ files = _wsdl2py(options, wsdl)
+ files.append(_wsdl2dispatch(options, wsdl))
if getattr(options, 'pydoc', False):
_writepydoc(os.path.join('docs', 'API'), *files)
Modified: trunk/zsi/ZSI/generate/containers.py
===================================================================
--- trunk/zsi/ZSI/generate/containers.py 2007-07-10 20:26:11 UTC (rev 1406)
+++ trunk/zsi/ZSI/generate/containers.py 2007-07-11 00:09:00 UTC (rev 1407)
@@ -586,10 +586,9 @@
elif self.soap_input_headers:
method = [
'%s# op: %s' % (ID1, self.name),
- '%sdef %s(self, request, soapheaders=()):' % (ID1, self.name),
+ '%sdef %s(self, request, soapheaders=(), **kw):' % (ID1, self.name),
'%s%s' % (ID2, tCheck),
'%sraise TypeError, "%%s incorrect request type" %% (%s)' %(ID3, 'request.__class__'),
- '%s%s' % (ID2, kwstring),
'%s%s' % (ID2, wsactionIn),
'%s# TODO: Check soapheaders' % (ID2),
'%sself.binding.Send(None, None, request, soapaction="%s", soapheaders=soapheaders, %s'\
@@ -598,10 +597,9 @@
else:
method = [
'%s# op: %s' % (ID1, self.name),
- '%sdef %s(self, request):' % (ID1, self.name),
+ '%sdef %s(self, request, **kw):' % (ID1, self.name),
'%s%s' % (ID2, tCheck),
'%sraise TypeError, "%%s incorrect request type" %% (%s)' %(ID3, 'request.__class__'),
- '%s%s' % (ID2, kwstring),
'%s%s' % (ID2, wsactionIn),
'%sself.binding.Send(None, None, request, soapaction="%s", %s'\
%(ID2, self.soapaction, bindArgs),
Modified: trunk/zsi/test/wsdl2py/config.txt
===================================================================
--- trunk/zsi/test/wsdl2py/config.txt 2007-07-10 20:26:11 UTC (rev 1406)
+++ trunk/zsi/test/wsdl2py/config.txt 2007-07-11 00:09:00 UTC (rev 1407)
@@ -179,3 +179,6 @@
test_Racing = wsdl/Racing.wsdl
test_NVOAdmin = wsdl/nvo-admin.wsdl
+test_Clearspace = http://eval.jivesoftware.com/clearspace/rpc/soap/BlogService?wsdl
+
+
Added: trunk/zsi/test/wsdl2py/test_Clearspace.py
===================================================================
--- trunk/zsi/test/wsdl2py/test_Clearspace.py (rev 0)
+++ trunk/zsi/test/wsdl2py/test_Clearspace.py 2007-07-11 00:09:00 UTC (rev 1407)
@@ -0,0 +1,98 @@
+#!/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
+
+"""
+Unittest for contacting Clearspace blog webservice
+
+WSDL:
+"""
+
+# General targets
+def dispatch():
+ """Run all dispatch tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(ServiceTest, 'test_dispatch'))
+ return suite
+
+def local():
+ """Run all local tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(ServiceTest, 'test_local'))
+ return suite
+
+def net():
+ """Run all network tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(ServiceTest, 'test_net'))
+ return suite
+
+def all():
+ """Run all tests"""
+ suite = ServiceTestSuite()
+ suite.addTest(unittest.makeSuite(ServiceTest, 'test_'))
+ return suite
+
+
+# NEED TO CREATE WSSE typecodes
+from ZSI.generate.commands import wsdl2py
+if not os.path.isdir('stubs'): os.makedirs('stubs')
+wsdl2py(['--complexType', '--schema','--output-dir=stubs', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'])
+
+
+class BlogServiceTest(ServiceTestCase):
+ """Test case for Clearspace sandbox, example how to use client WSSE:Security UsernameToken Profile
+
+<wsdl:Envelope xmlns:soap="..." xmlns:wsse="..." >
+ <wsdl:Header>
+ <wsse:Security>
+ <wsse:UsernameToken>
+ <wsse:Username>admin</wsse:Username>
+ <wsse:Password>password</wsse:Password>
+ </wsse:UsernameToken>
+ </wsse:Security>
+ </wsdl:Header>
+</wsdl:Envelope>
+
+ """
+ name = "test_Clearspace"
+ client_file_name = "BlogService_client.py"
+ types_file_name = "BlogService_types.py"
+ server_file_name = "BlogService_server.py"
+
+ def __init__(self, methodName):
+ ServiceTestCase.__init__(self, methodName)
+ self.wsdl2py_args.append('-b')
+
+ def _get_soap_headers(self):
+ import oasis_200401_wss_wssecurity_secext_1_0_xsd_types
+ from ZSI.schema import GED
+ security = GED("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security").pyclass()
+ token = GED("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken").pyclass()
+ security.Any = [token]
+ token.Username = 'billy'
+ klass = GED("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Password").pyclass
+ token.Any = [klass('guest'),]
+
+ return (security,)
+
+ def test_net_Blogcount(self):
+ loc = self.client_module.BlogServiceLocator()
+ msg = self.client_module.getBlogCountRequest()
+ port = loc.getBlogServiceHttpPort(**self.getPortKWArgs())
+ rsp = port.getBlogCount(msg, soapheaders=self._get_soap_headers(),)
+
+ def test_local_(self):
+ import oasis_200401_wss_wssecurity_secext_1_0_xsd_types
+ return
+
+ServiceTest = BlogServiceTest
+
+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...> - 2007-07-10 20:26:08
|
Revision: 1406
http://svn.sourceforge.net/pywebsvcs/?rev=1406&view=rev
Author: boverhof
Date: 2007-07-10 13:26:11 -0700 (Tue, 10 Jul 2007)
Log Message:
-----------
_M ZSI
-- change externals property because of sourceforge svn changes
Property Changed:
----------------
trunk/zsi/ZSI/
Property changes on: trunk/zsi/ZSI
___________________________________________________________________
Name: svn:externals
- wstools https://svn.sourceforge.net/svnroot/pywebsvcs/trunk/wstools
+ wstools https://pywebsvcs.svn.sourceforge.net/svnroot/pywebsvcs/trunk/wstools
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-10 20:25:41
|
Revision: 1405
http://svn.sourceforge.net/pywebsvcs/?rev=1405&view=rev
Author: boverhof
Date: 2007-07-10 13:25:44 -0700 (Tue, 10 Jul 2007)
Log Message:
-----------
M XMLSchema.py
-- If one tries to grab a schema item using the helper methods, if that item doesn't exist and the namespace is not in the BUILT_IN_NAMESPACES list then throw a SchemaError. Now failure to specify an import dependency will result in an error like:
ZSI.wstools.XMLSchema.SchemaError: schema "urn:webservices" does not import namespace "urn:base"
when "item.getTypeDefinition()" is called and the "type" attribute value QName is in a namespace that hasn't been declared as a dependency
So basically this throws errors when can't find a schema item that is supposed to be defined, rather than just returning None most of the time, which is always an error condition.
M a Utility.py
-- use M2Crypto if available for TimeOutSocket, and standard "ssl" if it's not
--
Modified Paths:
--------------
trunk/wstools/Utility.py
trunk/wstools/XMLSchema.py
Modified: trunk/wstools/Utility.py
===================================================================
--- trunk/wstools/Utility.py 2007-07-07 00:46:05 UTC (rev 1404)
+++ trunk/wstools/Utility.py 2007-07-10 20:25:44 UTC (rev 1405)
@@ -159,14 +159,19 @@
# If ssl is not compiled into Python, you will not get an exception
# until a conn.endheaders() call. We need to know sooner, so use
# getattr.
- if hasattr(socket, 'ssl'):
+ try:
+ import M2Crypto
+ except ImportError:
+ if not hasattr(socket, 'ssl'):
+ raise RuntimeError, 'no built-in SSL Support'
+
conn = TimeoutHTTPS(host, None, timeout)
else:
- import M2Crypto
ctx = M2Crypto.SSL.Context()
ctx.set_session_timeout(timeout)
conn = M2Crypto.httpslib.HTTPSConnection(host, ssl_context=ctx)
- #conn.set_debuglevel(1)
+ conn.set_debuglevel(1)
+
else:
conn = TimeoutHTTP(host, None, timeout)
Modified: trunk/wstools/XMLSchema.py
===================================================================
--- trunk/wstools/XMLSchema.py 2007-07-07 00:46:05 UTC (rev 1404)
+++ trunk/wstools/XMLSchema.py 2007-07-10 20:25:44 UTC (rev 1405)
@@ -15,7 +15,7 @@
ident = "$Id$"
import types, weakref, sys, warnings
-from Namespaces import SCHEMA, XMLNS
+from Namespaces import SCHEMA, XMLNS, SOAP
from Utility import DOM, DOMException, Collection, SplitQName, basejoin
from StringIO import StringIO
@@ -37,8 +37,8 @@
ATTRIBUTES = 'attr_decl'
ELEMENTS = 'elements'
MODEL_GROUPS = 'model_groups'
+BUILT_IN_NAMESPACES = [SOAP.ENC,] + SCHEMA.XSD_LIST
-
def GetSchema(component):
"""convience function for finding the parent XMLSchema instance.
"""
@@ -574,16 +574,22 @@
attribute -- an information item attribute, with a QName value.
collection -- collection in parent Schema instance to search.
"""
- obj = None
tdc = self.getAttributeQName(attribute)
- if tdc:
- obj = self.getSchemaItem(collection, tdc.getTargetNamespace(), tdc.getName())
+ if not tdc:
+ return
- return obj
+ obj = self.getSchemaItem(collection, tdc.getTargetNamespace(), tdc.getName())
+ if obj:
+ return obj
+# raise SchemaError, 'No schema item "%s" in collection %s' %(tdc, collection)
+ return
+
def getSchemaItem(self, collection, namespace, name):
"""returns object instance representing namespace, name,
- or if does not exist return None.
+ or if does not exist return None if built-in, else
+ raise SchemaError.
+
namespace -- namespace item defined in.
name -- name of item.
collection -- collection in parent Schema instance to search.
@@ -599,8 +605,14 @@
return obj
if not parent.imports.has_key(namespace):
- return None
-
+ if namespace in BUILT_IN_NAMESPACES:
+ # built-in just return
+ # WARNING: expecting import if "redefine" or add to built-in namespace.
+ return
+
+ raise SchemaError, 'schema "%s" does not import namespace "%s"' %(
+ parent.targetNamespace, namespace)
+
# Lazy Eval
schema = parent.imports[namespace]
if not isinstance(schema, XMLSchema):
@@ -609,6 +621,10 @@
parent.imports[namespace] = schema
if schema is None:
+ if namespace in BUILT_IN_NAMESPACES:
+ # built-in just return
+ return
+
raise SchemaError, 'no schema instance for imported namespace (%s).'\
%(namespace)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-07 00:46:03
|
Revision: 1404
http://svn.sourceforge.net/pywebsvcs/?rev=1404&view=rev
Author: boverhof
Date: 2007-07-06 17:46:05 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
M ZSI/generate/commands.py
-- store_true not store
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-07-07 00:33:48 UTC (rev 1403)
+++ trunk/zsi/ZSI/generate/commands.py 2007-07-07 00:46:05 UTC (rev 1404)
@@ -115,7 +115,7 @@
help="map element names directly to python attributes")
op.add_option("-p", "--pydoc",
- action="store", dest="pydoc", default=False,
+ action="store_true", dest="pydoc", default=False,
help="top-level directory for pydoc documentation.")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-07 00:33:45
|
Revision: 1403
http://svn.sourceforge.net/pywebsvcs/?rev=1403&view=rev
Author: boverhof
Date: 2007-07-06 17:33:48 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
M ZSI/generate/commands.py
-- adding a pydoc option to generate API docs.
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-07-06 22:51:32 UTC (rev 1402)
+++ trunk/zsi/ZSI/generate/commands.py 2007-07-07 00:33:48 UTC (rev 1403)
@@ -114,6 +114,11 @@
action="store_true", dest="simple_naming", default=False,
help="map element names directly to python attributes")
+ op.add_option("-p", "--pydoc",
+ action="store", dest="pydoc", default=False,
+ help="top-level directory for pydoc documentation.")
+
+
is_cmdline = args is None
if is_cmdline:
(options, args) = op.parse_args()
@@ -149,6 +154,10 @@
files = _wsdl2py(options, wsdl)
files.append(_wsdl2dispatch(options, wsdl))
+
+ if getattr(options, 'pydoc', False):
+ _writepydoc(os.path.join('docs', 'API'), *files)
+
if is_cmdline:
return
@@ -266,4 +275,257 @@
self.name = '_'.join(split(location)[-1].split('.'))
self.types = {schema.targetNamespace:schema}
+
+
+
+import os, pydoc, sys, warnings, inspect
+import os.path
+from distutils import log
+from distutils.command.build_py import build_py
+from distutils.util import convert_path
+
+#from setuptools import find_packages
+#from setuptools import Command
+from ZSI.schema import ElementDeclaration, TypeDefinition
+#from pyGridWare.utility.generate.Modules import NR
+#from pyGridWare.utility.generate.Modules import CLIENT, TYPES
+
+#def find_packages_modules(where='.'):
+# #pack,mod,mod_file
+# """Return a list all Python packages found within directory 'where'
+# """
+# out = []
+# stack=[(convert_path(where), '')]
+# while stack:
+# where,prefix = stack.pop(0)
+# for name in os.listdir(where):
+# fn = os.path.join(where,name)
+# #if (os.path.isdir(fn) and
+# # os.path.isfile(os.path.join(fn,'__init__.py'))
+# #):
+# # out.append(prefix+name); stack.append((fn,prefix+name+'.'))
+# if (os.path.isdir(fn) and
+# os.path.isfile(os.path.join(fn,'__init__.py'))):
+# stack.append((fn,prefix+name+'.'))
+# continue
+#
+# if name == '__init__.py' or not name.endswith('.py'):
+# continue
+#
+# out.append((prefix, name.split('.py')[0]))
+#
+# return out
+
+
+def _writedoc(doc, thing, forceload=0):
+ """Write HTML documentation to a file in the current directory.
+ """
+ try:
+ object, name = pydoc.resolve(thing, forceload)
+ page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
+ fname = os.path.join(doc, name + '.html')
+ file = open(fname, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ traceback.print_exc(sys.stderr)
+ else:
+ return name + '.html'
+
+
+def _writeclientdoc(doc, thing, forceload=0):
+ """Write HTML documentation to a file in the current directory.
+ """
+ docmodule = pydoc.HTMLDoc.docmodule
+ def strongarm(self, object, name=None, mod=None, *ignored):
+ result = docmodule(self, object, name, mod, *ignored)
+
+ # Grab all the aliases to pyclasses and create links.
+ nonmembers = []
+ push = nonmembers.append
+ for k,v in inspect.getmembers(object, inspect.isclass):
+ if inspect.getmodule(v) is not object and getattr(v,'typecode',None) is not None:
+ push('<a href="%s.html">%s</a>: pyclass alias<br/>' %(v.__name__,k))
+
+ result += self.bigsection('Aliases', '#ffffff', '#eeaa77', ''.join(nonmembers))
+ return result
+
+ pydoc.HTMLDoc.docmodule = strongarm
+ try:
+ object, name = pydoc.resolve(thing, forceload)
+ page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
+ name = os.path.join(doc, name + '.html')
+ file = open(name, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+
+ pydoc.HTMLDoc.docmodule = docmodule
+
+def _writetypesdoc(doc, thing, forceload=0):
+ """Write HTML documentation to a file in the current directory.
+ """
+ try:
+ object, name = pydoc.resolve(thing, forceload)
+ name = os.path.join(doc, name + '.html')
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+ return
+
+ # inner classes
+ cdict = {}
+ fdict = {}
+ elements_dict = {}
+ types_dict = {}
+ for kname,klass in inspect.getmembers(thing, inspect.isclass):
+ if thing is not inspect.getmodule(klass):
+ continue
+
+ cdict[kname] = inspect.getmembers(klass, inspect.isclass)
+ for iname,iklass in cdict[kname]:
+ key = (kname,iname)
+ fdict[key] = _writedoc(doc, iklass)
+ if issubclass(iklass, ElementDeclaration):
+
+ try:
+ typecode = iklass()
+ except (AttributeError,RuntimeError), ex:
+ elements_dict[iname] = _writebrokedoc(doc, ex, iname)
+ continue
+
+ elements_dict[iname] = None
+ if typecode.pyclass is not None:
+ elements_dict[iname] = _writedoc(doc, typecode.pyclass)
+
+ continue
+
+ if issubclass(iklass, TypeDefinition):
+ try:
+ typecode = iklass(None)
+ except (AttributeError,RuntimeError), ex:
+ types_dict[iname] = _writebrokedoc(doc, ex, iname)
+ continue
+
+ types_dict[iname] = None
+ if typecode.pyclass is not None:
+ types_dict[iname] = _writedoc(doc, typecode.pyclass)
+
+ continue
+
+
+ def strongarm(self, object, name=None, mod=None, funcs={}, classes={}, *ignored):
+ """Produce HTML documentation for a class object."""
+ realname = object.__name__
+ name = name or realname
+ bases = object.__bases__
+ object, name = pydoc.resolve(object, forceload)
+ contents = []
+ push = contents.append
+ if name == realname:
+ title = '<a name="%s">class <strong>%s</strong></a>' % (
+ name, realname)
+ else:
+ title = '<strong>%s</strong> = <a name="%s">class %s</a>' % (
+ name, name, realname)
+
+ mdict = {}
+ if bases:
+ parents = []
+ for base in bases:
+ parents.append(self.classlink(base, object.__module__))
+ title = title + '(%s)' % pydoc.join(parents, ', ')
+
+ doc = self.markup(pydoc.getdoc(object), self.preformat, funcs, classes, mdict)
+ doc = doc and '<tt>%s<br> </tt>' % doc
+ for iname,iclass in cdict[name]:
+ fname = fdict[(name,iname)]
+
+ if elements_dict.has_key(iname):
+ push('class <a href="%s">%s</a>: element declaration typecode<br/>'\
+ %(fname,iname))
+ pyclass = elements_dict[iname]
+ if pyclass is not None:
+ push('<ul>instance attributes:')
+ push('<li><a href="%s">pyclass</a>: instances serializable to XML<br/></li>'\
+ %elements_dict[iname])
+ push('</ul>')
+ elif types_dict.has_key(iname):
+ push('class <a href="%s">%s</a>: type definition typecode<br/>' %(fname,iname))
+ pyclass = types_dict[iname]
+ if pyclass is not None:
+ push('<ul>instance attributes:')
+ push('<li><a href="%s">pyclass</a>: instances serializable to XML<br/></li>'\
+ %types_dict[iname])
+ push('</ul>')
+ else:
+ push('class <a href="%s">%s</a>: TODO not sure what this is<br/>' %(fname,iname))
+
+ contents = ''.join(contents)
+ return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)
+
+ doclass = pydoc.HTMLDoc.docclass
+ pydoc.HTMLDoc.docclass = strongarm
+
+ try:
+ page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
+ file = open(name, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+
+ pydoc.HTMLDoc.docclass = doclass
+
+
+
+def _writebrokedoc(doc, ex, name, forceload=0):
+ try:
+ fname = os.path.join(doc, name + '.html')
+ page = pydoc.html.page(pydoc.describe(ex), pydoc.html.document(str(ex), fname))
+ file = open(fname, 'w')
+ file.write(page)
+ file.close()
+ except (ImportError, pydoc.ErrorDuringImport), value:
+ log.debug(str(value))
+
+ return name + '.html'
+
+def _writepydoc(doc, *args):
+ """create pydoc html pages
+ doc -- destination directory for documents
+ *args -- modules run thru pydoc
+ """
+ ok = True
+ if not os.path.isdir(doc):
+ os.makedirs(doc)
+
+ if os.path.curdir not in sys.path:
+ sys.path.append(os.path.curdir)
+
+ for f in args:
+ if f.startswith('./'): f = f[2:]
+ name = os.path.sep.join(f.strip('.py').split(os.path.sep))
+ try:
+ e = __import__(name)
+ except Exception,ex:
+ raise
+# _writebrokedoc(doc, ex, name)
+# continue
+
+ if name.endswith('_client'):
+ _writeclientdoc(doc, e)
+ continue
+
+ if name.endswith('_types'):
+ _writetypesdoc(doc, e)
+ continue
+
+ try:
+ _writedoc(doc, e)
+ except IndexError,ex:
+ _writebrokedoc(doc, ex, name)
+ continue
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-06 22:51:32
|
Revision: 1402
http://svn.sourceforge.net/pywebsvcs/?rev=1402&view=rev
Author: boverhof
Date: 2007-07-06 15:51:32 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
A test/test_QName.py
M test/test_zsi.py
M test/test_zsi_net.py
-- added QName test for undeclared default namespace
M test/wsdl2py/test_AWSECommerceService.py
-- update amazon test to 6/13 version
M ZSI/generate/wsdl2dispatch.py
M ZSI/generate/wsdl2python.py
M ZSI/generate/commands.py
M ZSI/generate/containers.py
-- server skeleton generated with all "messages" so
it only needs to import the types
-- FIX [ 1731012 ] wsdl2py should include command-line options
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
trunk/zsi/ZSI/generate/containers.py
trunk/zsi/ZSI/generate/wsdl2dispatch.py
trunk/zsi/ZSI/generate/wsdl2python.py
trunk/zsi/test/test_zsi.py
trunk/zsi/test/test_zsi_net.py
trunk/zsi/test/wsdl2py/test_AWSECommerceService.py
Added Paths:
-----------
trunk/zsi/test/test_QName.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-07-06 18:35:46 UTC (rev 1401)
+++ trunk/zsi/ZSI/generate/commands.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -219,22 +219,13 @@
client_file = join(options.output_dir, '%s.py' %client_mod)
append(client_file)
fd = open(client_file, 'w+')
-
- # simple naming writes the messages to a separate file
- if not options.simple_naming:
- wsm.writeClient(fd)
- else: # provide a separate file to store messages to.
- msg_fd = open(join(options.output_dir,
- '%s.py' %(wsm.getMessagesModuleName()), 'w+' ))
- wsm.writeClient(fd, msg_fd=msg_fd)
- msg_fd.close()
-
+ wsm.writeClient(fd)
fd.close()
types_mod = wsm.getTypesModuleName()
types_file = join(options.output_dir, '%s.py' %types_mod)
append(types_file)
- fd = open( join(options.output_dir, '%s.py' %types_mod), 'w+' )
+ fd = open(types_file, 'w+' )
wsm.writeTypes(fd)
fd.close()
@@ -242,12 +233,12 @@
def _wsdl2dispatch(options, wsdl):
- if options.simple_naming:
- ServiceDescription.server_module_suffix = '_interface'
- ServiceDescription.func_aname = lambda instnc,n: TextProtect(n)
- ServiceDescription.separate_messages = True
- # use module names rather than their number.
- utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
+# if options.simple_naming:
+# ServiceDescription.server_module_suffix = '_interface'
+# ServiceDescription.func_aname = lambda instnc,n: TextProtect(n)
+# ServiceDescription.separate_messages = True
+# # use module names rather than their number.
+# utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
if options.address is True:
ss = ServiceDescriptionWSA()
Modified: trunk/zsi/ZSI/generate/containers.py
===================================================================
--- trunk/zsi/ZSI/generate/containers.py 2007-07-06 18:35:46 UTC (rev 1401)
+++ trunk/zsi/ZSI/generate/containers.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -306,6 +306,7 @@
imports = ['\nimport urlparse, types',
'from ZSI.TCcompound import ComplexType, Struct',
'from ZSI import client',
+ 'from ZSI.schema import GED, GTD',
'import ZSI'
]
logger = _GetLogger("ServiceHeaderContainer")
@@ -913,13 +914,16 @@
kw = KW.copy()
- kw['message'],kw['prefix'],kw['typecode'] = \
- self.content.mName, self.getNSAlias(), element_class_name(self.content.pName)
+ kw.update(dict(message=self.content.mName, nsuri=self.content.ns,
+ name=self.content.pName))
+# kw['message'],kw['prefix'],kw['typecode'] = \
+# self.content.mName, self.getNSAlias(), element_class_name(self.content.pName)
+#
# These messsages are just global element declarations
- self.writeArray(['%(message)s = %(prefix)s.%(typecode)s().pyclass' %kw])
+# self.writeArray(['%(message)s = %(prefix)s.%(typecode)s().pyclass' %kw])
+ self.writeArray(['%(message)s = GED("%(nsuri)s", "%(name)s").pyclass' %kw])
-
class ServiceRPCEncodedMessageContainer(ServiceContainerBase, MessageContainerInterface):
logger = _GetLogger("ServiceRPCEncodedMessageContainer")
Modified: trunk/zsi/ZSI/generate/wsdl2dispatch.py
===================================================================
--- trunk/zsi/ZSI/generate/wsdl2dispatch.py 2007-07-06 18:35:46 UTC (rev 1401)
+++ trunk/zsi/ZSI/generate/wsdl2dispatch.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -2,14 +2,15 @@
from cStringIO import StringIO
import ZSI, string, sys, getopt, urlparse, types, warnings
from ZSI.wstools import WSDLTools
-from ZSI.generate.wsdl2python import WriteServiceModule, MessageTypecodeContainer
from ZSI.ServiceContainer import ServiceSOAPBinding, SimpleWSResource, WSAResource
-from ZSI.generate.utility import TextProtect, GetModuleBaseNameFromWSDL, \
+
+from ZSI.generate import WsdlGeneratorError, Wsdl2PythonError
+from utility import TextProtect, GetModuleBaseNameFromWSDL, \
NCName_to_ClassName, GetPartsSubNames, TextProtectAttributeName
-from ZSI.generate import WsdlGeneratorError, Wsdl2PythonError
-from ZSI.generate.wsdl2python import SchemaDescription
+from containers import BindingDescription
+from wsdl2python import MessageWriter, WriteServiceModule,\
+ MessageTypecodeContainer, SchemaDescription
-
# Split last token
rsplit = lambda x,sep,: (x[:x.rfind(sep)], x[x.rfind(sep)+1:],)
if sys.version_info[0:2] == (2, 4, 0, 'final', 0)[0:2]:
@@ -54,9 +55,10 @@
self.header = None
self.imports = None
+ self.messages = []
self._services = None
- self.client_module_path = None
- self.client_module_name = None
+ self.types_module_path = None
+ self.types_module_name = None
self.messages_module_name = None
def _getBaseClassName(self):
@@ -82,6 +84,7 @@
def reset(self):
self.header = StringIO()
self.imports = StringIO()
+ self.message = []
self._services = {}
def getIndent(self, level=1):
@@ -100,28 +103,31 @@
'''
return NCName_to_ClassName(name)
- def setClientModuleName(self, name):
- self.client_module_name = name
+ def setTypesModuleName(self, name):
+ self.types_module_name = name
- def getClientModuleName(self):
+ # Backwards compatibility
+ setClientModuleName = setTypesModuleName
+
+ def getTypesModuleName(self):
'''return module name.
'''
assert self.wsdl is not None, 'initialize, call fromWSDL'
- if self.client_module_name is not None:
- return self.client_module_name
+ if self.types_module_name is not None:
+ return self.types_module_name
wsm = WriteServiceModule(self.wsdl)
- return wsm.getClientModuleName()
+ return wsm.getTypesModuleName()
- def getMessagesModuleName(self):
- '''return module name.
- '''
- assert self.wsdl is not None, 'initialize, call fromWSDL'
- if self.messages_module_name is not None:
- return self.messages_module_name
-
- wsm = WriteServiceModule(self.wsdl)
- return wsm.getMessagesModuleName()
+# def getMessagesModuleName(self):
+# '''return module name.
+# '''
+# assert self.wsdl is not None, 'initialize, call fromWSDL'
+# if self.messages_module_name is not None:
+# return self.messages_module_name
+#
+# wsm = WriteServiceModule(self.wsdl)
+# return wsm.getMessagesModuleName()
def getServiceModuleName(self):
'''return module name.
@@ -134,14 +140,16 @@
return name
return '%s%s' %(name, self.server_module_suffix)
- def getClientModulePath(self):
- return self.client_module_path
-
- def setClientModulePath(self, path):
+ def getTypesModulePath(self):
+ return self.types_module_path
+ getClientModulePath = getTypesModulePath
+
+ def setTypesModulePath(self, path):
'''setup module path to where client module before calling fromWSDL.
'''
- self.client_module_path = path
-
+ self.types_module_path = path
+ setClientModulePath = setTypesModulePath
+
def setUpClassDef(self, service):
'''set class definition and class variables.
service -- ServiceDescription instance
@@ -162,19 +170,27 @@
def setUpImports(self):
'''set import statements
'''
- path = self.getClientModulePath()
i = self.imports
- if path is None:
- if self.separate_messages:
- print >>i, 'from %s import *' %self.getMessagesModuleName()
- else:
- print >>i, 'from %s import *' %self.getClientModuleName()
- else:
- if self.separate_messages:
- print >>i, 'from %s.%s import *' %(path, self.getMessagesModuleName())
- else:
- print >>i, 'from %s.%s import *' %(path, self.getClientModuleName())
+ print >>i, 'from ZSI.schema import GED, GTD'
+ print >>i, 'from ZSI.TCcompound import ComplexType, Struct'
+# if path is None:
+# if self.separate_messages:
+# print >>i, 'from %s import *' %self.getMessagesModuleName()
+# else:
+# print >>i, 'from %s import *' %self.getClientModuleName()
+# else:
+# if self.separate_messages:
+# print >>i, 'from %s.%s import *' %(path, self.getMessagesModuleName())
+# else:
+# print >>i, 'from %s.%s import *' %(path, self.getClientModuleName())
+ module = self.getTypesModuleName()
+ package = self.getTypesModulePath()
+ if package:
+ module = '%s.%s' %(package, module)
+
+ print >>i, 'from %s import *' %(module)
+
mod = self._getBaseClassModule()
name = self._getBaseClassName()
if mod is None and name is None:
@@ -267,11 +283,13 @@
return
def setUpHeader(self):
- print >>self.header, '##################################################'
- print >>self.header, '# %s.py' %self.getServiceModuleName()
- print >>self.header, '# Generated by %s' %(self.__class__)
+ print >>self.header, '#'*50
+ print >>self.header, '# file: %s.py' %self.getServiceModuleName()
print >>self.header, '#'
- print >>self.header, '##################################################'
+ print >>self.header, '# skeleton generated by "%s"' %self.__class__
+ print >>self.header, '# %s' %' '.join(sys.argv)
+ print >>self.header, '#'
+ print >>self.header, '#'*50
def write(self, fd=sys.stdout):
'''write out to file descriptor,
@@ -279,6 +297,14 @@
'''
print >>fd, self.header.getvalue()
print >>fd, self.imports.getvalue()
+
+ print >>fd, '# Messages ',
+ for m in self.messages:
+ print >>fd, m
+
+ print >>fd, ''
+ print >>fd, ''
+ print >>fd, '# Service Skeletons'
for k,v in self._services.items():
print >>fd, v.classdef.getvalue()
print >>fd, v.initdef.getvalue()
@@ -293,16 +319,32 @@
if len(wsdl.services) == 0:
raise WsdlGeneratorError, 'No service defined'
-
+
self.reset()
self.wsdl = wsdl
self.setUpHeader()
self.setUpImports()
+
for service in wsdl.services:
sd = self._service_class(service.name)
self._services[service.name] = sd
for port in service.ports:
+ desc = BindingDescription(wsdl=wsdl)
+ try:
+ desc.setUp(port.getBinding())
+ except Wsdl2PythonError, ex:
+ continue
+
+ for soc in desc.operations:
+ if not soc.hasInput(): continue
+
+ self.messages.append(MessageWriter())
+ self.messages[-1].setUp(soc, port, input=True)
+ if soc.hasOutput():
+ self.messages.append(MessageWriter())
+ self.messages[-1].setUp(soc, port, input=False)
+
for e in port.extensions:
if isinstance(e, WSDLTools.SoapAddressBinding):
sd.location = e.location
@@ -346,10 +388,12 @@
'''use soapAction dict for WS-Action input, setup wsAction
dict for grabbing WS-Action output values.
'''
- assert isinstance(service, WSDLTools.Service), 'expecting WSDLTools.Service instance'
+ assert isinstance(service, WSDLTools.Service), \
+ 'expecting WSDLTools.Service instance'
s = self._services[service.name].classdef
- print >>s, 'class %s(%s):' %(self.getClassName(service.name), self._getBaseClassName())
+ print >>s, 'class %s(%s):' %(self.getClassName(service.name),
+ self._getBaseClassName())
print >>s, '%ssoapAction = {}' % self.getIndent(level=1)
print >>s, '%swsAction = {}' % self.getIndent(level=1)
print >>s, '%sroot = {}' % self.getIndent(level=1)
Modified: trunk/zsi/ZSI/generate/wsdl2python.py
===================================================================
--- trunk/zsi/ZSI/generate/wsdl2python.py 2007-07-06 18:35:46 UTC (rev 1401)
+++ trunk/zsi/ZSI/generate/wsdl2python.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -7,7 +7,7 @@
# $Id$
-import os, warnings
+import os, sys, warnings
from ZSI import _get_idstr
from ZSI.wstools.logging import getLogger as _GetLogger
from ZSI.wstools import WSDLTools
@@ -83,19 +83,19 @@
return '%s%s' %(name, self.client_module_suffix)
- def getMessagesModuleName(self):
- name = GetModuleBaseNameFromWSDL(self._wsdl)
- if not name:
- raise WsdlGeneratorError, 'could not determine a service name'
-
- if self.messages_module_suffix is None:
- return name
+# def getMessagesModuleName(self):
+# name = GetModuleBaseNameFromWSDL(self._wsdl)
+# if not name:
+# raise WsdlGeneratorError, 'could not determine a service name'
+#
+# if self.messages_module_suffix is None:
+# return name
+#
+# if len(self.messages_module_suffix) == 0:
+# return self.getClientModuleName()
+#
+# return '%s%s' %(name, self.messages_module_suffix)
- if len(self.messages_module_suffix) == 0:
- return self.getClientModuleName()
-
- return '%s%s' %(name, self.messages_module_suffix)
-
def setTypesModuleName(self, name):
self.types_module_name = name
@@ -125,11 +125,11 @@
"""
return self.types_module_path
- def getMessagesModulePath(self):
- '''module path to messages module
- same as types path
- '''
- return self.messages_module_path
+# def getMessagesModulePath(self):
+# '''module path to messages module
+# same as types path
+# '''
+# return self.messages_module_path
def setTypesModulePath(self, path):
"""setup module path to where service module before calling fromWsdl.
@@ -137,11 +137,11 @@
"""
self.types_module_path = path
- def setMessagesModulePath(self, path):
- """setup module path to where message module before calling fromWsdl.
- module path to types module eg. MyApp.types
- """
- self.messages_module_path = path
+# def setMessagesModulePath(self, path):
+# """setup module path to where message module before calling fromWsdl.
+# module path to types module eg. MyApp.types
+# """
+# self.messages_module_path = path
def gatherNamespaces(self):
'''This method must execute once.. Grab all schemas
@@ -174,11 +174,10 @@
self.usedNamespaces[k].append(v)
NAD.add(k)
- def writeClient(self, fd, sdClass=None, msg_fd=None, **kw):
+ def writeClient(self, fd, sdClass=None, **kw):
"""write out client module to file descriptor.
Parameters and Keywords arguments:
fd -- file descriptor
- msg_fd -- optional messsages module file descriptor
sdClass -- service description class name
imports -- list of imports
readerclass -- class name of ParsedSoap reader
@@ -188,40 +187,47 @@
assert issubclass(sdClass, ServiceDescription), \
'parameter sdClass must subclass ServiceDescription'
- header = '%s \n# %s.py \n# generated by %s\n%s\n\n'\
- %('#'*50, self.getClientModuleName(), self.__module__, '#'*50)
- fd.write(header)
+# header = '%s \n# %s.py \n# generated by %s\n%s\n'\
+# %('#'*50, self.getClientModuleName(), self.__module__, '#'*50)
+ print >>fd, '#'*50
+ print >>fd, '# file: %s.py' %self.getClientModuleName()
+ print >>fd, '# '
+ print >>fd, '# client stubs generated by "%s"' %self.__class__
+ print >>fd, '# %s' %' '.join(sys.argv)
+ print >>fd, '# '
+ print >>fd, '#'*50
- if msg_fd is not None:
- # TODO: Why is this not getMessagesModuleName?
- msg_filename = str(self.getClientModuleName()).replace("client", "messages")
- if self.getMessagesModulePath() is not None:
- msg_filename = os.path.join(self.getMessagesModulePath(), msg_filename)
- messages_header = header.replace("client", "messages")
- msg_fd.write(messages_header)
-
self.services = []
for service in self._wsdl.services:
- sd = sdClass(self._addressing, do_extended=self.do_extended, wsdl=self._wsdl)
+ sd = sdClass(self._addressing, do_extended=self.do_extended,
+ wsdl=self._wsdl)
if len(self._wsdl.types) > 0:
- sd.setTypesModuleName(self.getTypesModuleName(), self.getTypesModulePath())
- sd.setMessagesModuleName(self.getMessagesModuleName(), self.getMessagesModulePath())
+ sd.setTypesModuleName(self.getTypesModuleName(),
+ self.getTypesModulePath())
+# sd.setMessagesModuleName(self.getMessagesModuleName(),
+# self.getMessagesModulePath())
self.gatherNamespaces()
sd.fromWsdl(service, **kw)
- sd.write(fd,msg_fd)
+ sd.write(fd)
self.services.append(sd)
def writeTypes(self, fd):
"""write out types module to file descriptor.
"""
- header = '%s \n# %s.py \n# generated by %s\n%s\n\n'\
- %('#'*50, self.getTypesModuleName(), self.__module__, '#'*50)
- fd.write(header)
+ print >>fd, '#'*50
+ print >>fd, '# file: %s.py' %self.getTypesModuleName()
+ print >>fd, '#'
+ print >>fd, '# schema types generated by "%s"' %self.__class__
+ print >>fd, '# %s' %' '.join(sys.argv)
+ print >>fd, '#'
+ print >>fd, '#'*50
+
print >>fd, TypesHeaderContainer()
self.gatherNamespaces()
for l in self.usedNamespaces.values():
- sd = SchemaDescription(do_extended=self.do_extended, extPyClasses=self.extPyClasses)
+ sd = SchemaDescription(do_extended=self.do_extended,
+ extPyClasses=self.extPyClasses)
for schema in l:
sd.fromSchema(schema)
sd.write(fd)
@@ -254,20 +260,20 @@
if modulePath is not None:
self.typesModuleName = '%s.%s' %(modulePath,name)
- def setMessagesModuleName(self, name, modulePath=None):
- '''The types module to be imported.
- Parameters
- name -- name of types module
- modulePath -- optional path where module is located.
- '''
- self.messagesModuleName = '%s' %name
- if modulePath is not None:
- self.messagesModuleName = '%s.%s' %(modulePath,name)
+# def setMessagesModuleName(self, name, modulePath=None):
+# '''The types module to be imported.
+# Parameters
+# name -- name of types module
+# modulePath -- optional path where module is located.
+# '''
+# self.messagesModuleName = '%s' %name
+# if modulePath is not None:
+# self.messagesModuleName = '%s.%s' %(modulePath,name)
def fromWsdl(self, service, **kw):
self.imports.setTypesModuleName(self.typesModuleName)
- if self.separate_messages:
- self.messagesImports.setMessagesModuleName(self.messagesModuleName)
+# if self.separate_messages:
+# self.messagesImports.setMessagesModuleName(self.messagesModuleName)
self.imports.appendImport(kw.get('imports', []))
self.locator.setUp(service)
@@ -284,7 +290,9 @@
while port.binding in bindings:
bindings.remove(port.binding)
- desc = BindingDescription(useWSA=self.wsAddressing, do_extended=self.do_extended, wsdl=self._wsdl)
+ desc = BindingDescription(useWSA=self.wsAddressing,
+ do_extended=self.do_extended,
+ wsdl=self._wsdl)
try:
desc.setUp(port.getBinding())
except Wsdl2PythonError, ex:
@@ -314,22 +322,22 @@
fd -- file descriptor to write out service description.
msg_fd -- optional file descriptor for messages module.
"""
- if msg_fd != None:
- print >>fd, self.messagesImports
- print >>msg_fd, self.imports
- else:
- print >>fd, self.imports
+# if msg_fd != None:
+# print >>fd, self.messagesImports
+# print >>msg_fd, self.imports
+# else:
+ print >>fd, self.imports
print >>fd, self.locator
for m in self.bindings:
print >>fd, m
- if msg_fd != None:
- for m in self.messages:
- print >>msg_fd, m
- else:
- for m in self.messages:
- print >>fd, m
+# if msg_fd != None:
+# for m in self.messages:
+# print >>msg_fd, m
+# else:
+ for m in self.messages:
+ print >>fd, m
class MessageWriter:
Added: trunk/zsi/test/test_QName.py
===================================================================
--- trunk/zsi/test/test_QName.py (rev 0)
+++ trunk/zsi/test/test_QName.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -0,0 +1,67 @@
+#!/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
+"""
+
+
+class TestCase(unittest.TestCase):
+ def check_soapfault_faultcode(self):
+ """ Typecode QName when default namespace is not declared, should
+ specify the empty namespace.
+ """
+ msg = """<?xml version="1.0" encoding="UTF-8"?>
+<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<soapenv:Body>
+<soapenv:Fault>
+ <faultcode>ServerFaultCode</faultcode>
+ <faultstring>Operation failed since VMware tools are not running in this virtual machine.</faultstring>
+ <detail>
+ <ToolsUnavailableFault xmlns="urn:vim2"/>
+ </detail>
+</soapenv:Fault>
+</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')
+
+
+#
+# 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 2007-07-06 18:35:46 UTC (rev 1401)
+++ trunk/zsi/test/test_zsi.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -13,6 +13,7 @@
import test_TCtimes
import test_URI
import test_rfc2617
+import test_QName
def makeTestSuite():
return unittest.TestSuite(
Modified: trunk/zsi/test/test_zsi_net.py
===================================================================
--- trunk/zsi/test/test_zsi_net.py 2007-07-06 18:35:46 UTC (rev 1401)
+++ trunk/zsi/test/test_zsi_net.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -1,24 +1,11 @@
#!/usr/bin/env python
-import unittest
-import test_t1
-import test_t2
-import test_t3
import test_t4
-import test_t5
-import test_t6
-import test_t7
-import test_t8
-import test_t9
-import test_union
-import test_TCtimes
-import test_URI
-import test_list
-import test_rfc2617
import test_callhome
+from test_zsi import *
def makeTestSuite():
return unittest.TestSuite(
- map(lambda t: globals()[t].makeTestSuite(),
+ map(lambda t: globals()[t].makeTestSuite(),
filter(lambda g: g.startswith('test_') and True, globals()))
)
Modified: trunk/zsi/test/wsdl2py/test_AWSECommerceService.py
===================================================================
--- trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2007-07-06 18:35:46 UTC (rev 1401)
+++ trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2007-07-06 22:51:32 UTC (rev 1402)
@@ -42,7 +42,7 @@
return suite
-TargetNamespace = "http://webservices.amazon.com/AWSECommerceService/2007-05-14"
+TargetNamespace = "http://webservices.amazon.com/AWSECommerceService/2007-06-13"
class AmazonTestCase(ServiceTestCase):
"""Test case for Amazon ECommerce Web service
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-07-06 18:35:44
|
Revision: 1401
http://svn.sourceforge.net/pywebsvcs/?rev=1401&view=rev
Author: boverhof
Date: 2007-07-06 11:35:46 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
M RELEASE
-- python is now in svn not cvs
M ZSI/twisted/wsgi.py
-- couple main functions for testing
M ZSI/TC.py
FIX [ 1749290 ] TC.QName default namespace error
Modified Paths:
--------------
trunk/zsi/RELEASE
trunk/zsi/ZSI/TC.py
trunk/zsi/ZSI/twisted/wsgi.py
Modified: trunk/zsi/RELEASE
===================================================================
--- trunk/zsi/RELEASE 2007-06-29 22:50:57 UTC (rev 1400)
+++ trunk/zsi/RELEASE 2007-07-06 18:35:46 UTC (rev 1401)
@@ -123,12 +123,11 @@
- Get the LaTeX version of the documentation package and unpack it.
Create the symlink to .../Python-Doc-VERSION/tools/mkhowto.
-- Get them from CVS. If you have an existing Python checkout, you can
+- Get them from SVN. If you have an existing Python checkout, you can
symlink to the .../Doc/tools/mkhowto script in that. If not, then
you only need to check out the Doc/ tree::
- cvs -d :pserver:ano...@cv...:/cvsroot/python \
- checkout -d someplace python/dist/src/Doc
+ svn co http://svn.python.org/projects/python/trunk/Doc python-Do
The symlink can then be made to .../someplace/tools/mkhowto.
Modified: trunk/zsi/ZSI/TC.py
===================================================================
--- trunk/zsi/ZSI/TC.py 2007-06-29 22:50:57 UTC (rev 1400)
+++ trunk/zsi/ZSI/TC.py 2007-07-06 18:35:46 UTC (rev 1401)
@@ -782,6 +782,7 @@
'''
prefix,localName = SplitQName(text)
nsdict = ps.GetElementNSdict(elt)
+ prefix = prefix or ''
try:
namespaceURI = nsdict[prefix]
except KeyError, ex:
Modified: trunk/zsi/ZSI/twisted/wsgi.py
===================================================================
--- trunk/zsi/ZSI/twisted/wsgi.py 2007-06-29 22:50:57 UTC (rev 1400)
+++ trunk/zsi/ZSI/twisted/wsgi.py 2007-07-06 18:35:46 UTC (rev 1401)
@@ -15,7 +15,46 @@
from ZSI.twisted.reverse import DataHandler, ReverseHandlerChain,\
HandlerChainInterface
+"""
+WSGI Module
+unstable
+
+EXAMPLE APPLICATION:
+#
+from EchoServer_client import *
+from ZSI.twisted.wsgi import SOAPApplication, soapmethod, SOAPHandlerChainFactory
+
+class EchoService(SOAPApplication):
+ factory = SOAPHandlerChainFactory
+ wsdl_content = dict(name='', targetNamespace='', imports=(), portType='')
+
+ @soapmethod(EchoRequest.typecode, EchoResponse.typecode, operation='Echo', soapaction='Echo')
+ def soap_Echo(self, request, response, **kw):
+ response.EchoResult = request.EchoIn
+ return request,response
+
+
+def main():
+ from wsgiref.simple_server import make_server, demo_app
+ application = WSGIApplication()
+ httpd = make_server('', 8000, application)
+ application['echo'] = EchoService()
+ httpd.serve_forever()
+
+def main_twisted():
+ from ZSI.twisted.wsgi import test, WSGIApplication
+ app = WSGIApplication()
+ app['echo'] = EchoService()
+ test(app)
+
+if __name__ == '__main__':
+ main_twisted()
+
+"""
+
+
+
def soapmethod(requesttypecode, responsetypecode, soapaction='',
operation=None, **kw):
"""@soapmethod
@@ -116,6 +155,29 @@
"""
start_response("404 ERROR", [('Content-Type','text/plain')])
return ['Move along people, there is nothing to see to hear']
+
+ def putChild(self, path, resource):
+ """
+ """
+ path = path.split('/')
+ lp = len(path)
+ if lp == 0:
+ raise RuntimeError, 'bad path "%s"' %path
+
+ if lp == 1:
+ self[path[0]] = resource
+
+ for i in range(len(path)):
+ if not path[i]: continue
+ break
+
+ next = self.get(path[i], None)
+ if next is None:
+ next = self[path[i]] = WSGIApplication()
+
+ next.putChild('/'.join(path[-1:]), resource)
+
+
class SOAPApplication(WSGIApplication):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-29 22:50:58
|
Revision: 1400
http://svn.sourceforge.net/pywebsvcs/?rev=1400&view=rev
Author: boverhof
Date: 2007-06-29 15:50:57 -0700 (Fri, 29 Jun 2007)
Log Message:
-----------
M test/test_t8.py
M test/wsdl2py/servers/BasicServer.py
M test/wsdl2py/servers/DateService.py
M test/wsdl2py/servers/SquareService.py
M test/wsdl2py/servers/EchoWSAddr200403Server.py
M test/wsdl2py/servers/EchoServer.py
M test/wsdl2py/servers/FinancialService.py
M test/wsdl2py/servers/WhiteMesa.py
M ZSI/twisted/wsgi.py
M ZSI/dispatch.py
M ZSI/__init__.py
M ZSI/ServiceProxy.py
M ZSI/ServiceContainer.py
M ZSI/generate/wsdl2dispatch.py
M ZSI/generate/commands.py
M ZSI/TC.py
M ZSI/client.py
-- update server to return request,response
making some changes so can use ~same generated code for
ServiceContainer, WSGI, twisted, etc
-- added UNICODE_ENCODING="utf-8" that use, changed
TC.String to encode all parsed strings to expected
encoding. Should be no issues, except maybe expected
type (unicode vs. string), since utf-8 is superset of ascii
the default codec
Modified Paths:
--------------
trunk/zsi/ZSI/ServiceContainer.py
trunk/zsi/ZSI/ServiceProxy.py
trunk/zsi/ZSI/TC.py
trunk/zsi/ZSI/__init__.py
trunk/zsi/ZSI/client.py
trunk/zsi/ZSI/dispatch.py
trunk/zsi/ZSI/generate/commands.py
trunk/zsi/ZSI/generate/wsdl2dispatch.py
trunk/zsi/ZSI/twisted/wsgi.py
trunk/zsi/test/test_t8.py
trunk/zsi/test/wsdl2py/servers/BasicServer.py
trunk/zsi/test/wsdl2py/servers/DateService.py
trunk/zsi/test/wsdl2py/servers/EchoServer.py
trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py
trunk/zsi/test/wsdl2py/servers/FinancialService.py
trunk/zsi/test/wsdl2py/servers/SquareService.py
trunk/zsi/test/wsdl2py/servers/WhiteMesa.py
Modified: trunk/zsi/ZSI/ServiceContainer.py
===================================================================
--- trunk/zsi/ZSI/ServiceContainer.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/ServiceContainer.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -103,9 +103,9 @@
try:
if isWSResource is True:
- result = method(ps, address)
+ request,result = method(ps, address)
else:
- result = method(ps)
+ request,result = method(ps)
except Exception, e:
return SendFault(FaultFromException(e, 0, sys.exc_info()[2]), **kw)
Modified: trunk/zsi/ZSI/ServiceProxy.py
===================================================================
--- trunk/zsi/ZSI/ServiceProxy.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/ServiceProxy.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -30,32 +30,31 @@
service that is described with WSDL. The proxy exposes methods
that reflect the methods of the remote web service."""
- def __init__(self, wsdl, url=None, service=None, port=None, tracefile=None,
- nsdict=None, transport=None, transdict=None,
+ def __init__(self, wsdl, url=None, service=None, port=None,
cachedir=os.path.join(os.path.expanduser('~'), '.zsi_service_proxy_dir'),
- asdict=True):
+ asdict=True, lazy=False, pyclass=False, force=False, **kw):
"""
Parameters:
wsdl -- URL of WSDL.
url -- override WSDL SOAP address location
service -- service name or index
port -- port name or index
- tracefile --
- nsdict -- key prefix to namespace mappings for serialization
- in SOAP Envelope.
- transport -- override default transports.
- transdict -- arguments to pass into HTTPConnection constructor.
cachedir -- where to store generated files
asdict -- use dicts, else use generated pyclass
+ lazy -- use lazy typecode evaluation
+ pyclass -- use pyclass_type metaclass adds properties, "new_", "set_,
+ "get_" methods for schema element and attribute declarations.
+ force -- regenerate all WSDL code, write over cache.
+
+ NOTE: all other **kw will be passed to the underlying
+ ZSI.client._Binding constructor.
+
"""
self._asdict = asdict
# client._Binding
- self._tracefile = tracefile
- self._nsdict = nsdict or {}
- self._transdict = transdict
- self._transport = transport
self._url = url
+ self._kw = kw
# WSDL
self._wsdl = wstools.WSDLTools.WSDLReader().loadFromURL(wsdl)
@@ -65,6 +64,9 @@
self._name = self._service.name
self._methods = {}
self._cachedir = cachedir
+ self._lazy = lazy
+ self._pyclass = pyclass
+ self._force = force
# Set up rpc methods for service/port
port = self._port
@@ -102,13 +104,19 @@
del cp; cp = None
option = location.replace(':', '-') # colons seem to screw up option
- if (cp is not None and cp.has_section(section) and
+ if (not self._force and cp is not None and cp.has_section(section) and
cp.has_option(section, option)):
types = cp.get(section, option)
else:
# dont do anything to anames
- containers.ContainerBase.func_aname = lambda instnc,n: str(n)
- files = commands.wsdl2py(['-o', cachedir, location])
+ if not self._pyclass:
+ containers.ContainerBase.func_aname = lambda instnc,n: str(n)
+
+ args = ['-o', cachedir, location]
+ if self._lazy: args.insert(0, '-l')
+ if self._pyclass: args.insert(0, '-b')
+ files = commands.wsdl2py(args)
+
if cp is None: cp = ConfigParser()
if not cp.has_section(section): cp.add_section(section)
types = filter(lambda f: f.endswith('_types.py'), files)[0]
@@ -144,10 +152,10 @@
types = cp.get(section, option)
else:
# dont do anything to anames
- containers.ContainerBase.func_aname = lambda instnc,n: str(n)
+ if not self._pyclass:
+ containers.ContainerBase.func_aname = lambda instnc,n: str(n)
+
from ZSI.wstools import XMLSchema
-
-
reader = XMLSchema.SchemaReader(base_url=location)
if xml is not None and isinstance(xml, basestring):
schema = reader.loadFromString(xml)
@@ -164,6 +172,9 @@
schema = True
simple_naming = False
address = False
+ lazy = self._lazy
+ complexType = self._pyclass
+
schema.location = location
files = commands._wsdl2py(options, schema)
if cp is None: cp = ConfigParser()
@@ -205,10 +216,9 @@
if len(method.callinfo.inparams) == len(kwargs):
callinfo = method.callinfo
- binding = _Binding(tracefile=self._tracefile,
- url=self._url or callinfo.location,
- nsdict=self._nsdict,
- soapaction=callinfo.soapAction)
+ binding = _Binding(url=self._url or callinfo.location,
+ soapaction=callinfo.soapAction,
+ **self._kw)
kw = dict(unique=True)
if callinfo.use == 'encoded':
Modified: trunk/zsi/ZSI/TC.py
===================================================================
--- trunk/zsi/ZSI/TC.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/TC.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -8,7 +8,7 @@
_find_arraytype, _find_default_namespace, _find_href, _find_encstyle, \
_resolve_prefix, _find_xsi_attr, _find_type, \
_find_xmlns_prefix, _get_element_nsuri_name, _get_idstr, \
- _Node, EvaluateException, \
+ _Node, EvaluateException, UNICODE_ENCODING, \
_valid_encoding, ParseException
from ZSI.wstools.Namespaces import SCHEMA, SOAP
@@ -708,16 +708,19 @@
def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data.
+ Encode all strings as UTF-8, which will be type 'str'
+ not 'unicode'
'''
if self.strip: text = text.strip()
if self.pyclass is not None:
- return self.pyclass(text)
- return text
+ return self.pyclass(text.encode(UNICODE_ENCODING))
+ return text.encode(UNICODE_ENCODING)
def get_formatted_content(self, pyobj):
if type(pyobj) not in _stringtypes:
pyobj = str(pyobj)
- if type(pyobj) == types.UnicodeType: pyobj = pyobj.encode('utf-8')
+ if type(pyobj) == unicode:
+ return pyobj.encode(UNICODE_ENCODING)
return pyobj
Modified: trunk/zsi/ZSI/__init__.py
===================================================================
--- trunk/zsi/ZSI/__init__.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/__init__.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -150,8 +150,8 @@
##
## Public constants.
from ZSI.wstools.Namespaces import ZSI_SCHEMA_URI
+UNICODE_ENCODING = 'utf-8'
-
##
## Not public constants.
_inttypes = [ _types.IntType, _types.LongType ]
Modified: trunk/zsi/ZSI/client.py
===================================================================
--- trunk/zsi/ZSI/client.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/client.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -5,7 +5,8 @@
from ZSI import _copyright, _seqtypes, ParsedSoap, SoapWriter, TC, ZSI_SCHEMA_URI,\
EvaluateException, FaultFromFaultMessage, _child_elements, _attrs, _find_arraytype,\
- _find_type, _get_idstr, _get_postvalue_from_absoluteURI, FaultException, WSActionException
+ _find_type, _get_idstr, _get_postvalue_from_absoluteURI, FaultException, WSActionException,\
+ UNICODE_ENCODING
from ZSI.auth import AUTH
from ZSI.TC import AnyElement, AnyType, String, TypeCode, _get_global_element_declaration,\
_get_type_definition
@@ -300,7 +301,7 @@
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=utf-8')
+ self.h.putheader("Content-Type", 'text/xml; charset="%s"' %UNICODE_ENCODING)
self.__addcookies()
for header,value in headers.items():
Modified: trunk/zsi/ZSI/dispatch.py
===================================================================
--- trunk/zsi/ZSI/dispatch.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/dispatch.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -169,13 +169,13 @@
def _JonPySendXML(text, code=200, **kw):
req = kw['request']
- req.set_header("Content-Type", 'text/xml; charset="utf-8"')
+ req.set_header("Content-Type", 'text/xml; charset="%s"' %UNICODE_ENCODING)
req.set_header("Content-Length", str(len(text)))
req.write(text)
def _CGISendXML(text, code=200, **kw):
print 'Status: %d' % code
- print 'Content-Type: text/xml; charset="utf-8"'
+ print 'Content-Type: text/xml; charset="%s"' %UNICODE_ENCODING
print 'Content-Length: %d' % len(text)
print ''
print text
@@ -195,7 +195,7 @@
self.send_response(code)
if text:
- self.send_header('Content-type', 'text/xml; charset="utf-8"')
+ self.send_header('Content-type', 'text/xml; charset="%s"' %UNICODE_ENCODING)
self.send_header('Content-Length', str(len(text)))
self.end_headers()
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/generate/commands.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -16,9 +16,7 @@
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
-from ZSI.generate.wsdl2dispatch import DelAuthServiceModuleWriter as DelAuthServiceDescription
from ZSI.generate.wsdl2dispatch import WSAServiceModuleWriter as ServiceDescriptionWSA
-from ZSI.generate.wsdl2dispatch import DelAuthWSAServiceModuleWriter as DelAuthServiceDescriptionWSA
warnings.filterwarnings('ignore', '', exceptions.UserWarning)
Modified: trunk/zsi/ZSI/generate/wsdl2dispatch.py
===================================================================
--- trunk/zsi/ZSI/generate/wsdl2dispatch.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/generate/wsdl2dispatch.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -4,7 +4,8 @@
from ZSI.wstools import WSDLTools
from ZSI.generate.wsdl2python import WriteServiceModule, MessageTypecodeContainer
from ZSI.ServiceContainer import ServiceSOAPBinding, SimpleWSResource, WSAResource
-from ZSI.generate.utility import TextProtect, GetModuleBaseNameFromWSDL, NCName_to_ClassName, GetPartsSubNames, TextProtectAttributeName
+from ZSI.generate.utility import TextProtect, GetModuleBaseNameFromWSDL, \
+ NCName_to_ClassName, GetPartsSubNames, TextProtectAttributeName
from ZSI.generate import WsdlGeneratorError, Wsdl2PythonError
from ZSI.generate.wsdl2python import SchemaDescription
@@ -14,6 +15,7 @@
if sys.version_info[0:2] == (2, 4, 0, 'final', 0)[0:2]:
rsplit = lambda x,sep,: x.rsplit(sep, 1)
+
class SOAPService:
def __init__(self, service):
self.classdef = StringIO()
@@ -27,6 +29,7 @@
self.methods.append(StringIO())
return self.methods[-1]
+
class ServiceModuleWriter:
'''Creates a skeleton for a SOAP service instance.
'''
@@ -34,12 +37,14 @@
server_module_suffix = '_server'
func_aname = TextProtectAttributeName
func_aname = staticmethod(func_aname)
- separate_messages = False # Whether to write message definitions into a separate file.
+ separate_messages = False
- def __init__(self, base=ServiceSOAPBinding, prefix='soap', service_class=SOAPService, do_extended=False):
+ def __init__(self, base=ServiceSOAPBinding, prefix='soap',
+ service_class=SOAPService):
'''
parameters:
- base -- either a class definition, or a str representing a qualified class name.
+ base -- either a class definition, or a str representing a qualified
+ class name.
prefix -- method prefix.
'''
self.wsdl = None
@@ -53,16 +58,12 @@
self.client_module_path = None
self.client_module_name = None
self.messages_module_name = None
- self.do_extended = do_extended
- def reset(self):
- self.header = StringIO()
- self.imports = StringIO()
- self._services = {}
-
def _getBaseClassName(self):
'''return base class name, do not override.
'''
+ if self.base_class is None:
+ return
if type(self.base_class) is types.ClassType:
return self.base_class.__name__
return rsplit(self.base_class, '.')[-1]
@@ -70,12 +71,19 @@
def _getBaseClassModule(self):
'''return base class module, do not override.
'''
+ if self.base_class is None:
+ return
if type(self.base_class) is types.ClassType:
return self.base_class.__module__
if self.base_class.find('.') >= 0:
return rsplit(self.base_class, '.')[0]
- return None
+ return
+ def reset(self):
+ self.header = StringIO()
+ self.imports = StringIO()
+ self._services = {}
+
def getIndent(self, level=1):
'''return indent.
'''
@@ -102,7 +110,7 @@
if self.client_module_name is not None:
return self.client_module_name
- wsm = WriteServiceModule(self.wsdl, do_extended=self.do_extended)
+ wsm = WriteServiceModule(self.wsdl)
return wsm.getClientModuleName()
def getMessagesModuleName(self):
@@ -112,7 +120,7 @@
if self.messages_module_name is not None:
return self.messages_module_name
- wsm = WriteServiceModule(self.wsdl, do_extended=self.do_extended)
+ wsm = WriteServiceModule(self.wsdl)
return wsm.getMessagesModuleName()
def getServiceModuleName(self):
@@ -142,11 +150,15 @@
'expecting WSDLTools.Service instance.'
s = self._services[service.name].classdef
- print >>s, 'class %s(%s):' %(self.getClassName(service.name), self._getBaseClassName())
+ base = self._getBaseClassName()
+ if base is None:
+ print >>s, 'class %s:' %(self.getClassName(service.name))
+ else:
+ print >>s, 'class %s(%s):' %(self.getClassName(service.name), base)
+
print >>s, '%ssoapAction = {}' % self.getIndent(level=1)
print >>s, '%sroot = {}' % self.getIndent(level=1)
- print >>s, "%s_wsdl = \"\"\"%s\"\"\"" % (self.getIndent(level=1), self.raw_wsdl)
-
+
def setUpImports(self):
'''set import statements
'''
@@ -165,7 +177,9 @@
mod = self._getBaseClassModule()
name = self._getBaseClassName()
- if mod is None:
+ if mod is None and name is None:
+ pass
+ elif mod is None:
print >>i, 'import %s' %name
else:
print >>i, 'from %s import %s' %(mod, name)
@@ -173,7 +187,9 @@
def setUpInitDef(self, service):
'''set __init__ function
'''
- assert isinstance(service, WSDLTools.Service), 'expecting WSDLTools.Service instance.'
+ assert isinstance(service, WSDLTools.Service), \
+ 'expecting WSDLTools.Service instance.'
+
sd = self._services[service.name]
d = sd.initdef
@@ -183,9 +199,10 @@
else:
print >>d, '%sdef __init__(self, post, **kw):' %self.getIndent(level=1)
- print >>d, '%s%s.__init__(self, post)' %(self.getIndent(level=2),self._getBaseClassName())
+ base = self._getBaseClassName()
+ if base is not None:
+ print >>d, '%s%s.__init__(self, post)' %(self.getIndent(level=2), base)
-
def mangle(self, name):
return TextProtect(name)
@@ -230,81 +247,17 @@
m = sd.newMethod()
print >>m, '%sdef %s(self, ps):' %(self.getIndent(level=1), method_name)
if msgin is not None:
- print >>m, '%sself.request = ps.Parse(%s.typecode)' %(self.getIndent(level=2), msgin_name)
+ print >>m, '%srequest = ps.Parse(%s.typecode)' %(self.getIndent(level=2), msgin_name)
else:
print >>m, '%s# NO input' %self.getIndent(level=2)
msgout = op.getOutputMessage()
-
- if self.do_extended:
- input_args = msgin.parts.values()
- iargs = ["%s" % x.name for x in input_args]
- if msgout is not None:
- output_args = msgout.parts.values()
- else:
- output_args = []
- oargs = ["%s" % x.name for x in output_args]
- if output_args:
- if len(output_args) > 1:
- print "Message has more than one return value (Bad Design)."
- output_args = "(%s)" % output_args
- else:
- output_args = ""
- # Get arg list
- iSubNames = GetPartsSubNames(msgin.parts.values(), self.wsdl)
- for i in range( len(iargs) ): # should only be one part to messages here anyway
- argSubNames = iSubNames[i]
- if len(argSubNames) > 0:
- subNamesStr = "self.request." + ", self.request.".join(map(self.getAttributeName, argSubNames))
- if len(argSubNames) > 1:
- subNamesStr = "(" + subNamesStr + ")"
- print >>m, "%s%s = %s" % (self.getIndent(level=2), iargs[i], subNamesStr)
-
- print >>m, "\n%s# If we have an implementation object use it" % (self.getIndent(level=2))
- print >>m, "%sif hasattr(self,'impl'):" % (self.getIndent(level=2))
-
- iargsStrList = []
- for arg in iargs:
- argSubNames = iSubNames[i]
- if len(argSubNames) > 0:
- if len(argSubNames) > 1:
- for i in range(len(argSubNames)):
- iargsStrList.append( arg + "[%i]" % i )
- else:
- iargsStrList.append( arg )
- iargsStr = ",".join(iargsStrList)
- oargsStr = ", ".join(oargs)
- if len(oargsStr) > 0:
- oargsStr += " = "
- print >>m, "%s%sself.impl.%s(%s)" % (self.getIndent(level=3), oargsStr, op.name, iargsStr)
-
if msgout is not None:
msgout_name = TextProtect(msgout.name)
- if self.do_extended:
- print >>m, '\n%sresult = %s()' %(self.getIndent(level=2), msgout_name)
- oSubNames = GetPartsSubNames(msgout.parts.values(), self.wsdl)
- if (len(oSubNames) > 0) and (len(oSubNames[0]) > 0):
- print >>m, "%s# If we have an implementation object, copy the result " % (self.getIndent(level=2))
- print >>m, "%sif hasattr(self,'impl'):" % (self.getIndent(level=2))
- # copy result's members
- for i in range( len(oargs) ): # should only be one part messages here anyway
- oargSubNames = oSubNames[i]
- if len(oargSubNames) > 1:
- print >>m, '%s# Should have a tuple of %i args' %(self.getIndent(level=3), len(oargSubNames))
- for j in range(len(oargSubNames)):
- oargSubName = oargSubNames[j]
- print >>m, '%sresult.%s = %s[%i]' %(self.getIndent(level=3), self.getAttributeName(oargSubName), oargs[i], j)
- elif len(oargSubNames) == 1:
- oargSubName = oargSubNames[0]
- print >>m, '%sresult.%s = %s' %(self.getIndent(level=3), self.getAttributeName(oargSubName), oargs[i])
- else:
- raise Exception("The subnames within message " + msgout_name + "'s part were not found. Message is the output of operation " + op.name)
- print >>m, '%sreturn result' %(self.getIndent(level=2))
- else:
- print >>m, '%sreturn %s()' %(self.getIndent(level=2), msgout_name)
+ print >>m, '%sreturn request,%s()' %(self.getIndent(level=2), msgout_name)
else:
print >>m, '%s# NO output' % self.getIndent(level=2)
- print >>m, '%sreturn None' % self.getIndent(level=2)
+ print >>m, '%sreturn request,None' % self.getIndent(level=2)
print >>m, ''
print >>m, '%ssoapAction[\'%s\'] = \'%s\'' %(self.getIndent(level=1), action_in, method_name)
@@ -343,7 +296,6 @@
self.reset()
self.wsdl = wsdl
- self.raw_wsdl = wsdl.document.toxml().replace("\"", "\\\"")
self.setUpHeader()
self.setUpImports()
for service in wsdl.services:
@@ -364,7 +316,8 @@
class WSAServiceModuleWriter(ServiceModuleWriter):
'''Creates a skeleton for a WS-Address service instance.
'''
- def __init__(self, base=WSAResource, prefix='wsa', service_class=SOAPService, strict=True):
+ def __init__(self, base=WSAResource, prefix='wsa', service_class=SOAPService,
+ strict=True):
'''
Parameters:
strict -- check that soapAction and input ws-action do not collide.
@@ -379,12 +332,12 @@
'''
body = []
if msgInName is not None:
- body.append('self.request = ps.Parse(%s.typecode)' %msgInName)
+ body.append('request = ps.Parse(%s.typecode)' %msgInName)
if msgOutName is not None:
- body.append('return %s()' %msgOutName)
+ body.append('return request,%s()' %msgOutName)
else:
- body.append('return None')
+ body.append('return request,None')
return tuple(body)
createMethodBody = staticmethod(createMethodBody)
@@ -465,68 +418,3 @@
print >>m, '%sroot[(%s.typecode.nspname,%s.typecode.pname)] = \'%s\'' \
%(self.getIndent(level=1), msgin_name, msgin_name, method_name)
-
-class DelAuthServiceModuleWriter(ServiceModuleWriter):
- ''' Includes the generation of lines to call an authorization method on the server side
- if an authorization function has been defined.
- '''
- def __init__(self, base=ServiceSOAPBinding, prefix='soap', service_class=SOAPService, do_extended=False):
- ServiceModuleWriter.__init__(self, base=base, prefix=prefix, service_class=service_class, do_extended=do_extended)
-
- def fromWSDL(self, wsdl):
- ServiceModuleWriter.fromWSDL(self, wsdl)
- for service in wsdl.services:
- self.setUpAuthDef(service)
-
- def setUpInitDef(self, service):
- ServiceModuleWriter.setUpInitDef(self, service)
- sd = self._services[service.name]
- d = sd.initdef
- print >>d, '%sif kw.has_key(\'impl\'):' % self.getIndent(level=2)
- print >>d, '%sself.impl = kw[\'impl\']' % self.getIndent(level=3)
-
- print >>d, '%sself.auth_method_name = None' % self.getIndent(level=2)
- print >>d, '%sif kw.has_key(\'auth_method_name\'):' % self.getIndent(level=2)
- print >>d, '%sself.auth_method_name = kw[\'auth_method_name\']' % self.getIndent(level=3)
-
- def setUpAuthDef(self, service):
- '''set __auth__ function
- '''
- sd = self._services[service.name]
- e = sd.initdef
- print >>e, "%sdef authorize(self, auth_info, post, action):" % self.getIndent(level=1)
- print >>e, "%sif self.auth_method_name and hasattr(self.impl, self.auth_method_name):" % self.getIndent(level=2)
- print >>e, "%sreturn getattr(self.impl, self.auth_method_name)(auth_info, post, action)" % self.getIndent(level=3)
- print >>e, "%selse:" % self.getIndent(level=2)
- print >>e, "%sreturn 1" % self.getIndent(level=3)
-
-class DelAuthWSAServiceModuleWriter(WSAServiceModuleWriter):
- def __init__(self, base=SimpleWSResource, prefix='wsa', service_class=SOAPService, strict=True):
- WSAServiceModuleWriter.__init__(self, base=base, prefix=prefix, service_class=service_class, strict=strict)
-
- def fromWSDL(self, wsdl):
- WSAServiceModuleWriter.fromWSDL(self, wsdl)
- for service in wsdl.services:
- self.setUpAuthDef(service)
-
- def setUpInitDef(self, service):
- WSAServiceModuleWriter.setUpInitDef(self, service)
- sd = self._services[service.name]
- d = sd.initdef
- print >>d, '%sif kw.has_key(\'impl\'):' % self.getIndent(level=2)
- print >>d, '%sself.impl = kw[\'impl\']' % self.getIndent(level=3)
-
- print >>d, '%sif kw.has_key(\'auth_method_name\'):' % self.getIndent(level=2)
- print >>d, '%sself.auth_method_name = kw[\'auth_method_name\']' % self.getIndent(level=3)
-
- def setUpAuthDef(self, service):
- '''set __auth__ function
- '''
- sd = self._services[service.name]
- e = sd.initdef
- print >>e, "%sdef authorize(self, auth_info, post, action):" % self.getIndent(level=1)
- print >>e, "%sif self.auth_method_name and hasattr(self.impl, self.auth_method_name):" % self.getIndent(level=2)
- print >>e, "%sreturn getattr(self.impl, self.auth_method_name)(auth_info, post, action)" % self.getIndent(level=3)
- print >>e, "%selse:" % self.getIndent(level=2)
- print >>e, "%sreturn 1" % self.getIndent(level=3)
-
Modified: trunk/zsi/ZSI/twisted/wsgi.py
===================================================================
--- trunk/zsi/ZSI/twisted/wsgi.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/ZSI/twisted/wsgi.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -3,38 +3,44 @@
# See Copyright for copyright notice!
# $Id: __init__.py 1132 2006-02-17 01:55:41Z boverhof $
###########################################################################
-import os, sys, warnings
+import os, sys, types
from StringIO import StringIO
# twisted & related imports
from zope.interface import classProvides, implements, Interface
-from twisted.python import log, failure
-#from twisted.web.error import NoResource
-#from twisted.web.server import NOT_DONE_YET
-#import twisted.web.http
-#import twisted.web.resource
# ZSI imports
-from ZSI import _get_element_nsuri_name, EvaluateException, ParseException
-from ZSI import fault, ParsedSoap, SoapWriter
+from ZSI import _get_element_nsuri_name, EvaluateException, ParseException,\
+ fault, ParsedSoap, SoapWriter
+from ZSI.twisted.reverse import DataHandler, ReverseHandlerChain,\
+ HandlerChainInterface
-# WS-Address related imports
-from ZSI.address import Address
+def soapmethod(requesttypecode, responsetypecode, soapaction='',
+ operation=None, **kw):
+ """@soapmethod
+ decorator function for soap methods
+ """
+ def _closure(func_cb):
+ func_cb.root = (requesttypecode.nspname,requesttypecode.pname)
+ func_cb.action = soapaction
+ func_cb.requesttypecode = requesttypecode
+ func_cb.responsetypecode = responsetypecode
+ func_cb.soapmethod = True
+ func_cb.operation = None
+ return func_cb
+ return _closure
-class WSAddressException(Exception):
+
+class SOAPCallbackHandler:
+ """ ps --> pyobj, pyobj --> sw
+ class variables:
+ writerClass -- ElementProxy implementation to use for SoapWriter instances.
"""
- """
+ classProvides(HandlerChainInterface)
+ writerClass = None
-from ZSI.twisted.interfaces import HandlerChainInterface, CallbackChainInterface,\
- DataHandler, CheckInputArgs, DefaultHandlerChain
-
-
-
-class DefaultCallbackHandler:
- classProvides(CallbackChainInterface)
-
@classmethod
def processRequest(cls, ps, **kw):
"""invokes callback that should return a (request,response) tuple.
@@ -42,35 +48,47 @@
ps -- ParsedSoap instance representing HTTP Body.
request -- twisted.web.server.Request
"""
- #env = kw['env']
- #start_response = kw['start_response']
resource = kw['resource']
- #request = kw['request']
- method = getattr(resource, 'soap_%s' %
- _get_element_nsuri_name(ps.body_root)[-1])
-
+ request = kw['request']
+
+ root = _get_element_nsuri_name(ps.body_root)
+ for key,method in resource.__dict__:
+ if (callable(method) and
+ getattr(method, 'soapmethod', False) and
+ method.root == root):
+ break
+ else:
+ raise RuntimeError, 'Missing soap callback method for root "%s"' %root
+
try:
- req_pyobj,rsp_pyobj = method(ps)
- except TypeError, ex:
- log.err(
- 'ERROR: service %s is broken, method MUST return request, response'\
- % cls.__name__
- )
+ req = ps.Parse(method.requesttypecode)
+ except Exception, ex:
raise
+ try:
+ rsp = method.responsetypecode.pyclass()
except Exception, ex:
- log.err('failure when calling bound method')
raise
- return rsp_pyobj
+ try:
+ req,rsp = method(req, rsp)
+ except Exception, ex:
+ raise
+
+ return rsp
+
+ @classmethod
+ def processResponse(cls, output, **kw):
+ sw = SoapWriter(outputclass=cls.writerClass)
+ sw.serialize(output)
+ return sw
-class DefaultHandlerChainFactory:
- protocol = DefaultHandlerChain
-
+class SOAPHandlerChainFactory:
+ protocol = ReverseHandlerChain
+
@classmethod
def newInstance(cls):
- return cls.protocol(DefaultCallbackHandler, DataHandler)
-
+ return cls.protocol(DataHandler, SOAPCallbackHandler)
class WSGIApplication(dict):
@@ -104,8 +122,6 @@
"""
"""
factory = DefaultHandlerChainFactory
- soapAction = {}
- root = {}
def __init__(self, **kw):
dict.__init__(self, **kw)
@@ -130,7 +146,8 @@
def _handle_GET(self, env, start_response):
if env['QUERY_STRING'].lower() == 'wsdl':
start_response("200 OK", [('Content-Type','text/plain')])
- return ['NO WSDL YET']
+ r = self.delegate or self
+ return _resourceToWSDL(r)
start_response("404 ERROR", [('Content-Type','text/plain')])
return ['NO RESOURCE FOR GET']
@@ -168,7 +185,6 @@
def test(app, port=8080, host="localhost"):
"""
"""
- import sys
from twisted.internet import reactor
from twisted.python import log
from twisted.web2.channel import HTTPFactory
@@ -183,4 +199,77 @@
reactor.run()
+def _issoapmethod(f):
+ return type(f) is types.MethodType and getattr(f, 'soapmethod', False)
+def _resourceToWSDL(resource):
+ from xml.etree import ElementTree
+ from xml.etree.ElementTree import Element, QName
+ from ZSI.wstools.Namespaces import WSDL
+
+ r = resource
+ methods = filter(_issoapmethod, map(lambda i: getattr(r, i), dir(r)))
+ tns = ''
+
+ #tree = ElementTree()
+ defs = Element("{%s}definitions" %WSDL.BASE)
+ defs.attrib['name'] = 'SampleDefs'
+ defs.attrib['targetNamespace'] = tns
+ #tree.append(defs)
+
+ porttype = Element("{%s}portType" %WSDL)
+ porttype.attrib['name'] = QName("{%s}SamplePortType" %tns)
+
+ binding = Element("{%s}binding" %WSDL)
+ defs.append(binding)
+ binding.attrib['name'] = QName("{%s}SampleBinding" %tns)
+ binding.attrib['type'] = porttype.get('name')
+
+ for m in methods:
+ m.action
+
+ service = Element("{%s}service" %WSDL.BASE)
+ defs.append(service)
+ service.attrib['name'] = 'SampleService'
+
+ port = Element("{%s}port" %WSDL.BASE)
+ service.append(port)
+ port.attrib['name'] = "SamplePort"
+ port.attrib['binding'] = binding.get('name')
+
+ soapaddress = Element("{%s}address" %WSDL.BIND_SOAP)
+ soapaddress.attrib['location'] = 'http://localhost/bla'
+ port.append(soapaddress)
+
+ return [ElementTree.tostring(defs)]
+
+
+
+"""
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="Counter" targetNamespace="http://counter.com/bindings" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:porttype="http://counter.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <wsdl:import namespace="http://counter.com" location="counter_flattened.wsdl"/>
+ <wsdl:binding name="CounterPortTypeSOAPBinding" type="porttype:CounterPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="createCounter">
+ <soap:operation soapAction="http://counter.com/CounterPortType/createCounterRequest"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+
+<wsdl:definitions name="Counter" targetNamespace="http://counter.com/service"
+xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:binding="http://counter.com/bindings">
+ <wsdl:import namespace="http://counter.com/bindings" location="counter_bindings.wsdl"/>
+ <wsdl:service name="CounterService">
+ <wsdl:port name="CounterPortTypePort" binding="binding:CounterPortTypeSOAPBinding">
+ <soap:address location="http://localhost:8080/wsrf/services/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+"""
+
Modified: trunk/zsi/test/test_t8.py
===================================================================
--- trunk/zsi/test/test_t8.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/test_t8.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -73,7 +73,7 @@
self.assertEqual(type(myInt), type(parsed[0]))
self.assertEqual(type(myLong), type(parsed[1]))
- self.assertEqual(type(myStr), type(parsed[2]))
+ self.assertEqual(str, type(parsed[2]))
self.assertEqual(tuple, type(parsed[3]))
self.assertEqual(type(myFloat), type(parsed[4]))
Modified: trunk/zsi/test/wsdl2py/servers/BasicServer.py
===================================================================
--- trunk/zsi/test/wsdl2py/servers/BasicServer.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/wsdl2py/servers/BasicServer.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -14,17 +14,17 @@
class Service(BasicServer):
def soap_Basic(self, ps):
- response = BasicServer.soap_Basic(self, ps)
- response._BasicResult = self.request._BasicIn
- return response
+ request,response = BasicServer.soap_Basic(self, ps)
+ response._BasicResult = request._BasicIn
+ return request,response
def soap_BasicOneWay(self, ps):
- response = BasicServer.soap_BasicOneWay(self, ps)
- if self.request._BasicIn == 'fault':
+ request,response = BasicServer.soap_BasicOneWay(self, ps)
+ if request._BasicIn == 'fault':
# return a soap:fault
raise RuntimeError, 'you wanted a fault?'
- return response
+ return request,response
if __name__ == "__main__" :
Modified: trunk/zsi/test/wsdl2py/servers/DateService.py
===================================================================
--- trunk/zsi/test/wsdl2py/servers/DateService.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/wsdl2py/servers/DateService.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -9,18 +9,18 @@
class Service(_DateService):
def soap_getCurrentDate(self, ps):
- response = _DateService.soap_getCurrentDate(self, ps)
+ request,response = _DateService.soap_getCurrentDate(self, ps)
response.Today = today = response.new_today()
- self.request._input
+ request._input
_SetCurrentDate(today)
- return response
+ return request,response
def soap_getDate(self, ps):
- response = _DateService.soap_getDate(self, ps)
+ request,response = _DateService.soap_getDate(self, ps)
response.Day = day = response.new_day()
- _SetDay(day, offset=self.request.Offset,
- date=self.request.Someday)
- return response
+ _SetDay(day, offset=request.Offset,
+ date=request.Someday)
+ return request,response
## ADDED WORKER CODE
Modified: trunk/zsi/test/wsdl2py/servers/EchoServer.py
===================================================================
--- trunk/zsi/test/wsdl2py/servers/EchoServer.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/wsdl2py/servers/EchoServer.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -17,9 +17,9 @@
class Service(EchoServer):
def soap_Echo(self, ps):
- response = EchoServer.soap_Echo(self, ps)
- response.EchoResult = self.request.EchoIn
- return response
+ request,response = EchoServer.soap_Echo(self, ps)
+ response.EchoResult = request.EchoIn
+ return request,response
if __name__ == "__main__" :
Modified: trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py
===================================================================
--- trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -20,8 +20,8 @@
class WSAService(EchoServer):
def wsa_Echo(self, ps, addr):
- response = EchoServer.wsa_Echo(self, ps, addr)
- response.EchoResult = self.request.EchoIn
+ request,response = EchoServer.wsa_Echo(self, ps, addr)
+ response.EchoResult = request.EchoIn
if isinstance(response.EchoResult, EndpointReferenceType):
addr1 = response.EchoResult
@@ -29,7 +29,7 @@
if a not in addr1.ReferenceProperties.Any:
raise RuntimeError, 'EPRs dont match'
- return response
+ return request,response
if __name__ == "__main__" :
Modified: trunk/zsi/test/wsdl2py/servers/FinancialService.py
===================================================================
--- trunk/zsi/test/wsdl2py/servers/FinancialService.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/wsdl2py/servers/FinancialService.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -10,8 +10,8 @@
class Service(FinancialService):
def soap_getPV(self, ps):
- reponse = FinancialService.soap_getPV(self, ps)
- args = self.request
+ request,response = FinancialService.soap_getPV(self, ps)
+ args = request
# Worker code: Actual present value calculation
t = 0
@@ -27,8 +27,8 @@
# WARNING specify value eg. SimpleTypeWrapper(1)
#response = SimpleTypeWrapper(PV)
- response = reponse.__class__(PV)
- return response
+ response = response.__class__(PV)
+ return request,response
Modified: trunk/zsi/test/wsdl2py/servers/SquareService.py
===================================================================
--- trunk/zsi/test/wsdl2py/servers/SquareService.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/wsdl2py/servers/SquareService.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -10,9 +10,9 @@
class Service(Square.SquareService):
def soap_getSquare(self, ps):
- response = Square.SquareService.soap_getSquare(self, ps)
- response._return = self.getSquare(self.request._x)
- return response
+ request,response = Square.SquareService.soap_getSquare(self, ps)
+ response._return = self.getSquare(request._x)
+ return request,response
def getSquare(self, x):
return x**2
Modified: trunk/zsi/test/wsdl2py/servers/WhiteMesa.py
===================================================================
--- trunk/zsi/test/wsdl2py/servers/WhiteMesa.py 2007-06-19 15:59:55 UTC (rev 1399)
+++ trunk/zsi/test/wsdl2py/servers/WhiteMesa.py 2007-06-29 22:50:57 UTC (rev 1400)
@@ -15,36 +15,36 @@
class Service(WhiteMesa):
def soap_echoStruct(self, ps):
- response = WhiteMesa.soap_echoStruct(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoStruct(self, ps)
+ return request,response
def soap_echoStructArray(self, ps):
- response = WhiteMesa.soap_echoStructArray(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoStructArray(self, ps)
+ return request,response
def soap_echoStructAsSimpleTypes(self, ps):
- response = WhiteMesa.soap_echoStructAsSimpleTypes(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoStructAsSimpleTypes(self, ps)
+ return request,response
def soap_echoSimpleTypesAsStruct(self, ps):
- response = WhiteMesa.soap_echoSimpleTypesAsStruct(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoSimpleTypesAsStruct(self, ps)
+ return request,response
def soap_echoNestedStruct(self, ps):
- response = WhiteMesa.soap_echoNestedStruct(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoNestedStruct(self, ps)
+ return request,response
def soap_echoNestedArray(self, ps):
- response = WhiteMesa.soap_echoNestedArray(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoNestedArray(self, ps)
+ return request,response
def soap_echoStringArray(self, ps):
- response = WhiteMesa.soap_echoStringArray(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoStringArray(self, ps)
+ return request,response
def soap_echoIntegerArray(self, ps):
- response = WhiteMesa.soap_echoIntegerArray(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoIntegerArray(self, ps)
+ return request,response
def soap_echoBoolean(self, ps):
- response = WhiteMesa.soap_echoBoolean(self, ps)
- response._return = self.request._inputBoolean
- return response
+ request,response = WhiteMesa.soap_echoBoolean(self, ps)
+ response._return = request._inputBoolean
+ return request,response
def soap_echoString(self, ps):
- response = WhiteMesa.soap_echoString(self, ps)
- return response
+ request,response = WhiteMesa.soap_echoString(self, ps)
+ return request,response
if __name__ == "__main__" :
port = int(sys.argv[1])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eo...@us...> - 2007-06-19 15:59:55
|
Revision: 1399
http://svn.sourceforge.net/pywebsvcs/?rev=1399&view=rev
Author: eolson
Date: 2007-06-19 08:59:55 -0700 (Tue, 19 Jun 2007)
Log Message:
-----------
Dereference client transport handle at end of call.
Fix by turam at mcs.anl.gov.
Modified Paths:
--------------
branches/ZSI_v2_0_0/ZSI/client.py
Modified: branches/ZSI_v2_0_0/ZSI/client.py
===================================================================
--- branches/ZSI_v2_0_0/ZSI/client.py 2007-06-18 21:25:05 UTC (rev 1398)
+++ branches/ZSI_v2_0_0/ZSI/client.py 2007-06-19 15:59:55 UTC (rev 1399)
@@ -375,6 +375,7 @@
# Horrible internals hack to patch things up.
self.h._HTTPConnection__state = httplib._CS_REQ_SENT
self.h._HTTPConnection__response = None
+ self.h = None
return self.data
def IsSOAP(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-18 21:25:04
|
Revision: 1398
http://svn.sourceforge.net/pywebsvcs/?rev=1398&view=rev
Author: boverhof
Date: 2007-06-18 14:25:05 -0700 (Mon, 18 Jun 2007)
Log Message:
-----------
A ZSI/twisted/reverse.py
-- implementation for "reverse" handler chain
Added Paths:
-----------
trunk/zsi/ZSI/twisted/reverse.py
Added: trunk/zsi/ZSI/twisted/reverse.py
===================================================================
--- trunk/zsi/ZSI/twisted/reverse.py (rev 0)
+++ trunk/zsi/ZSI/twisted/reverse.py 2007-06-18 21:25:05 UTC (rev 1398)
@@ -0,0 +1,86 @@
+from ZSI import _get_element_nsuri_name, SoapWriter, ParsedSoap
+from ZSI.twisted.interfaces import HandlerChainInterface
+from zope.interface import classProvides, implements, Interface
+
+
+class DataHandler:
+ """ str --> ps, sw --> str
+ class variables:
+ readerClass -- factory class to create reader for ParsedSoap instances.
+ """
+ classProvides(HandlerChainInterface)
+ readerClass = None
+
+ @classmethod
+ def processRequest(cls, input, **kw):
+ return ParsedSoap(input, readerclass=cls.readerClass)
+
+ @classmethod
+ def processResponse(cls, sw, **kw):
+ return str(sw)
+
+
+class CallbackHandler:
+ """ ps --> pyobj, pyobj --> sw
+ class variables:
+ writerClass -- ElementProxy implementation to use for SoapWriter instances.
+ """
+ classProvides(HandlerChainInterface)
+ writerClass = None
+
+ @classmethod
+ def processRequest(cls, ps, **kw):
+ """invokes callback that should return a (request,response) tuple.
+ representing the SOAP request and response respectively.
+ ps -- ParsedSoap instance representing HTTP Body.
+ request -- twisted.web.server.Request
+ """
+ resource = kw['resource']
+ request = kw['request']
+ method = getattr(resource, 'soap_%s' %
+ _get_element_nsuri_name(ps.body_root)[-1])
+
+ try:
+ req,rsp = method(ps, request=request)
+ except Exception, ex:
+ raise
+
+ return rsp
+
+ @classmethod
+ def processResponse(cls, output, **kw):
+ sw = SoapWriter(outputclass=cls.writerClass)
+ sw.serialize(output)
+ return sw
+
+
+class ReverseHandlerChain:
+
+ def __init__(self, *handlers):
+ self.in_handlers = handlers
+ handlers = list(handlers); handlers.reverse()
+ self.out_handlers = tuple(handlers)
+
+ def processRequest(self, arg, **kw):
+ for h in self.in_handlers:
+ arg = h.processRequest(arg, **kw)
+
+ return arg
+
+ def processResponse(self, arg, **kw):
+ if arg is None:
+ return
+
+ for h in self.out_handlers:
+ arg = h.processResponse(arg, **kw)
+
+ return arg
+
+
+class ReverseHandlerChainFactory:
+ protocol = ReverseHandlerChain
+
+ @classmethod
+ def newInstance(cls):
+ return cls.protocol(DataHandler, CallbackHandler)
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-14 21:56:09
|
Revision: 1397
http://svn.sourceforge.net/pywebsvcs/?rev=1397&view=rev
Author: boverhof
Date: 2007-06-14 14:56:11 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
M ZSI/client.py
-- add namespace parameter to Binding (and thus NamedParamBinding), so can specify the wrapper's namespace.
Modified Paths:
--------------
trunk/zsi/ZSI/client.py
Modified: trunk/zsi/ZSI/client.py
===================================================================
--- trunk/zsi/ZSI/client.py 2007-06-14 19:48:27 UTC (rev 1396)
+++ trunk/zsi/ZSI/client.py 2007-06-14 21:56:11 UTC (rev 1397)
@@ -33,34 +33,53 @@
that calls back to the Binding object to make an RPC call.
'''
- def __init__(self, binding, name):
- self.binding, self.name = binding, name
+ def __init__(self, binding, name, namespace=None):
+ self.binding = binding
+ self.name = name
+ self.namespace = namespace
def __call__(self, *args):
- return self.binding.RPC(None, self.name, args,
+ nsuri = self.namespace
+ if nsuri is None:
+ return self.binding.RPC(None, self.name, args,
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/",
+ replytype=TC.Any(self.name+"Response"))
+
+ return self.binding.RPC(None, (nsuri,self.name), args,
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/",
- replytype=TC.Any(self.name+"Response"))
+ replytype=TC.Any((nsuri,self.name+"Response")))
class _NamedParamCaller:
'''Similar to _Caller, expect that there are named parameters
not positional.
'''
-
- def __init__(self, binding, name):
- self.binding, self.name = binding, name
-
+
+ def __init__(self, binding, name, namespace=None):
+ self.binding = binding
+ self.name = name
+ self.namespace = namespace
+
def __call__(self, **params):
# Pull out arguments that Send() uses
- kw = { }
+ kw = {}
for key in [ 'auth_header', 'nsdict', 'requesttypecode', 'soapaction' ]:
if params.has_key(key):
kw[key] = params[key]
del params[key]
- return self.binding.RPC(None, self.name, None,
+
+ nsuri = self.namespace
+ if nsuri is None:
+ return self.binding.RPC(None, self.name, None,
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/",
+ _args=params,
+ replytype=TC.Any(self.name+"Response", aslist=False),
+ **kw)
+
+ return self.binding.RPC(None, (nsuri,self.name), None,
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/",
_args=params,
- replytype=TC.Any(self.name+"Response", aslist=False),
+ replytype=TC.Any((nsuri,self.name+"Response"), aslist=False),
**kw)
@@ -458,9 +477,18 @@
gettypecode = staticmethod(lambda mod,e: getattr(mod, str(e.localName)).typecode)
logger = _GetLogger('ZSI.client.Binding')
- def __init__(self, typesmodule=None, **kw):
+ def __init__(self, url, namespace=None, typesmodule=None, **kw):
+ """
+ Parameters:
+ url -- location of service
+ namespace -- optional root element namespace
+ typesmodule -- optional response only. dict(name=typecode),
+ lookup for all children of root element.
+ """
self.typesmodule = typesmodule
- _Binding.__init__(self, **kw)
+ self.namespace = namespace
+
+ _Binding.__init__(self, url=url, **kw)
def __getattr__(self, name):
'''Return a callable object that will invoke the RPC method
@@ -469,7 +497,7 @@
if name[:2] == '__' and len(name) > 5 and name[-2:] == '__':
if hasattr(self, name): return getattr(self, name)
return getattr(self.__class__, name)
- return _Caller(self, name)
+ return _Caller(self, name, self.namespace)
def __parse_child(self, node):
'''for rpc-style map each message part to a class in typesmodule
@@ -524,7 +552,6 @@
self.address.checkResponse(ps, kw.get('wsaction'))
return reply
-
class NamedParamBinding(Binding):
@@ -540,7 +567,7 @@
if name[:2] == '__' and len(name) > 5 and name[-2:] == '__':
if hasattr(self, name): return getattr(self, name)
return getattr(self.__class__, name)
- return _NamedParamCaller(self, name)
+ return _NamedParamCaller(self, name, self.namespace)
if __name__ == '__main__': print _copyright
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-14 19:48:25
|
Revision: 1396
http://svn.sourceforge.net/pywebsvcs/?rev=1396&view=rev
Author: boverhof
Date: 2007-06-14 12:48:27 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
M ZSI/generate/commands.py
-- changed behavior of "wsdl2py" a bit, if you call it with "args" then it will
return the files names which ServiceProxy needs. If it's called via command-line
tool, "args" is None and it will return None.
From: sh...@me...
Subject: [Pywebsvcs-talk] wsdl2py return code
Date: June 7, 2007 8:51:16 PM PDT
To: pyw...@li...
In svn head wsdl2py utility on successful run returns 1
(for example runing on wsdl from zsi/test/wsdl2py/wsdl)
-- shell --
$wsdl2py -o /tmp/ Racing.wsdl
[u'/tmp/Racing_client.py', u'/tmp/Racing_types.py', u'Racing_server.py']
$echo $?
1
-- shell --
It was introduced in svn revision 1378 in chunk (sorry for git diff)
diff --git a/zsi/ZSI/generate/commands.py b/zsi/ZSI/generate/commands.py
index 40afb07..4a854f3 100644
--- a/zsi/ZSI/generate/commands.py
+++ b/zsi/ZSI/generate/commands.py
@@ -179,11 +179,11 @@ respectively.
if isinstance(wsdl, XMLSchema.XMLSchema):
wsdl.location = location
- _wsdl2py(options, wsdl)
- return
+ return _wsdl2py(options, wsdl)
- _wsdl2py(options, wsdl)
- _wsdl2dispatch(options, wsdl)
+ modules = _wsdl2py(options, wsdl)
+ modules.append(_wsdl2dispatch(options, wsdl))
+ return modules
Link to diff in sf repo
http://svn.sourceforge.net/viewvc/pywebsvcs/trunk/zsi/ZSI/generate/commands.py?view=diff&r1=1377&r2=1378
This behaviour breaks Makefile rules depending on zero return code of
successful wsdl2py invocation.
Pavel
Revision Links:
--------------
http://svn.sourceforge.net/pywebsvcs/?rev=1378&view=rev
Modified Paths:
--------------
trunk/zsi/ZSI/generate/commands.py
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-06-14 06:49:35 UTC (rev 1395)
+++ trunk/zsi/ZSI/generate/commands.py 2007-06-14 19:48:27 UTC (rev 1396)
@@ -5,6 +5,8 @@
############################################################################
import exceptions, sys, optparse, os, warnings, traceback
+from os.path import isfile, join, split
+
#from operator import xor
import ZSI
from ConfigParser import ConfigParser
@@ -18,6 +20,7 @@
from ZSI.generate.wsdl2dispatch import WSAServiceModuleWriter as ServiceDescriptionWSA
from ZSI.generate.wsdl2dispatch import DelAuthWSAServiceModuleWriter as DelAuthServiceDescriptionWSA
+
warnings.filterwarnings('ignore', '', exceptions.UserWarning)
def SetDebugCallback(option, opt, value, parser, *args, **kwargs):
setBasicLoggerDEBUG()
@@ -25,7 +28,9 @@
def SetPyclassMetaclass(option, opt, value, parser, *args, **kwargs):
"""set up pyclass metaclass for complexTypes"""
- from ZSI.generate.containers import ServiceHeaderContainer, TypecodeContainerBase, TypesHeaderContainer
+ from ZSI.generate.containers import ServiceHeaderContainer,\
+ TypecodeContainerBase, TypesHeaderContainer
+
TypecodeContainerBase.metaclass = kwargs['metaclass']
TypesHeaderContainer.imports.append(\
'from %(module)s import %(metaclass)s' %kwargs
@@ -45,45 +50,31 @@
TypecodeContainerBase.lazy = True
-def formatSchemaObject(fname, schemaObj):
- """ In the case of a 'schema only' generation (-s) this creates
- a fake wsdl object that will function w/in the adapters
- and allow the generator to do what it needs to do.
- """
-
- class fake:
- pass
- f = fake()
-
- if fname.rfind('/'):
- tmp = fname[fname.rfind('/') + 1 :].split('.')
- else:
- tmp = fname.split('.')
-
- f.name = '_'.join(tmp)
- f.types = { schemaObj.targetNamespace : schemaObj }
-
- return f
-
def wsdl2py(args=None):
- """Utility for automatically generating client/service interface code from a wsdl
-definition, and a set of classes representing element declarations and
-type definitions. By default invoking this script produces three files, each
-named after the wsdl definition name, in the current working directory.
-These files will end with '_client.py', '_types.py', '_server.py'
-respectively.
+ """Utility for automatically generating client/service interface code from
+ a wsdl definition, and a set of classes representing element declarations
+ and type definitions. By default invoking this script produces three files,
+ each named after the wsdl definition name, in the current working directory.
+
+ Generated Modules Suffix:
+ _client.py -- client locator, rpc proxy port, messages
+ _types.py -- typecodes representing
+ _server.py -- server-side bindings
+
+ Parameters:
+ args -- optional can provide arguments, rather than parsing
+ command-line.
+
+ return:
+ Default behavior is to return None, if args are provided then
+ return names of the generated files.
+
"""
op = optparse.OptionParser(usage="USAGE: %wsdl2py [options] WSDL",
description=wsdl2py.__doc__)
# Basic options
- #op.add_option("-f", "--file",
- # action="store", dest="file", default=None, type="string",
- # help="FILE to load wsdl from")
- #op.add_option("-u", "--url",
- # action="store", dest="url", default=None, type="string",
- # help="URL to load wsdl from")
op.add_option("-x", "--schema",
action="store_true", dest="schema", default=False,
help="process just the schema from an xsd file [no services]")
@@ -117,56 +108,34 @@
'metaclass':'pyclass_type'},
help="generate a twisted.web client/server, dependencies python>=2.4, Twisted>=2.0.0, TwistedWeb>=0.5.0")
- # Extended generation options
- #op.add_option("-e", "--extended",
- # action="store_true", dest="extended", default=False,
- # help="Do Extended code generation.")
- #op.add_option("-z", "--aname",
- # action="store", dest="aname", default=None, type="string",
- # help="pass in a function for attribute name creation")
- #op.add_option("-t", "--types",
- # action="store", dest="types", default=None, type="string",
- # help="file to load types from")
op.add_option("-o", "--output-dir",
action="store", dest="output_dir", default=".", type="string",
help="save files in directory")
+
op.add_option("-s", "--simple-naming",
action="store_true", dest="simple_naming", default=False,
help="map element names directly to python attributes")
- #op.add_option("-c", "--clientClassSuffix",
- # action="store", dest="clientClassSuffix", default=None, type="string",
- # help="Suffix to use for service client class (default \"SOAP\")")
- #op.add_option("-m", "--pyclassMapModule",
- # action="store", dest="pyclassMapModule", default=None, type="string",
- # help="Python file that maps external python classes to a schema type. The classes are used as the \"pyclass\" for that type. The module should contain a dict() called mapping in the format: mapping = {schemaTypeName:(moduleName.py,className) }")
-
- if args is None:
+
+ is_cmdline = args is None
+ if is_cmdline:
(options, args) = op.parse_args()
else:
(options, args) = op.parse_args(args)
- #if not xor(options.file is None, options.url is None):
- # print 'Must specify either --file or --url option'
- # sys.exit(os.EX_USAGE)
- #location = options.file
- #if options.url is not None:
- # location = options.url
if len(args) != 1:
print>>sys.stderr, 'Expecting a file/url as argument (WSDL).'
sys.exit(os.EX_USAGE)
location = args[0]
-
if options.schema is True:
reader = XMLSchema.SchemaReader(base_url=location)
else:
reader = WSDLTools.WSDLReader()
load = reader.loadFromFile
- if not os.path.isfile(location):
+ if not isfile(location):
load = reader.loadFromURL
- wsdl = None
try:
wsdl = load(location)
except Exception, e:
@@ -180,104 +149,23 @@
wsdl.location = location
return _wsdl2py(options, wsdl)
- modules = _wsdl2py(options, wsdl)
- modules.append(_wsdl2dispatch(options, wsdl))
- return modules
+ files = _wsdl2py(options, wsdl)
+ files.append(_wsdl2dispatch(options, wsdl))
+ if is_cmdline:
+ return
+ return files
-def _wsdl2py(options, wsdl):
- if options.simple_naming:
- # Use a different client suffix
- # WriteServiceModule.client_module_suffix = "_client"
- # Write messages definitions to a separate file.
- #wsdl2pyServiceDescription.separate_messages = True
- # Use more simple type and element class names
- containers.SetTypeNameFunc( lambda n: '%s_' %(NC_to_CN(n)) )
- containers.SetElementNameFunc( lambda n: '%s' %(NC_to_CN(n)) )
- # Don't add "_" to the attribute name (remove when --aname works well)
- containers.ContainerBase.func_aname = lambda instnc,n: TextProtect(str(n))
- # write out the modules with their names rather than their number.
- utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
- #if options.clientClassSuffix:
- # from ZSI.generate.containers import ServiceContainerBase
- # ServiceContainerBase.clientClassSuffix = options.clientClassSuffix
-
- if options.schema is True:
- wsdl = formatSchemaObject(wsdl.location, wsdl)
-
- #if options.aname is not None:
- # args = options.aname.rsplit('.',1)
- # assert len(args) == 2, 'expecting module.function'
- # # The following exec causes a syntax error.
- # #exec('from %s import %s as FUNC' %(args[0],args[1]))
- # assert callable(FUNC),\
- # '%s must be a callable method with one string parameter' %options.aname
- # from ZSI.generate.containers import TypecodeContainerBase
- # TypecodeContainerBase.func_aname = staticmethod(FUNC)
-
- #if options.pyclassMapModule != None:
- # mod = __import__(options.pyclassMapModule)
- # components = options.pyclassMapModule.split('.')
- # for comp in components[1:]:
- # mod = getattr(mod, comp)
- # extPyClasses = mod.mapping
- #else:
- # extPyClasses = None
-
- #wsm = WriteServiceModule(wsdl, addressing=options.address, do_extended=options.extended, extPyClasses=extPyClasses)
- wsm = WriteServiceModule(wsdl, addressing=options.address)
-# if options.types != None:
-# wsm.setTypesModuleName(options.types)
-
- files = []
- append = files.append
- if options.schema is False:
- client_mod = wsm.getClientModuleName()
- client_file = os.path.join(options.output_dir, '%s.py' %client_mod)
- append(client_file)
- fd = open(client_file, 'w+')
-
- # simple naming writes the messages to a separate file
- if not options.simple_naming:
- wsm.writeClient(fd)
- else: # provide a separate file to store messages to.
- msg_fd = open( os.path.join(options.output_dir, '%s.py' %wsm.getMessagesModuleName()), 'w+' )
- wsm.writeClient(fd, msg_fd=msg_fd)
- msg_fd.close()
- fd.close()
-
-
- types_mod = wsm.getTypesModuleName()
- types_file = os.path.join(options.output_dir, '%s.py' %types_mod)
- append(types_file)
- fd = open( os.path.join(options.output_dir, '%s.py' %types_mod), 'w+' )
- wsm.writeTypes(fd)
- fd.close()
- return files
-
-
def wsdl2dispatch(args=None):
- """
- wsdl2dispatch
-
+ """Deprecated: wsdl2py now generates everything
A utility for automatically generating service skeleton code from a wsdl
definition.
"""
-
op = optparse.OptionParser()
-# op.add_option("-f", "--file",
-# action="store", dest="file", default=None, type="string",
-# help="file to load wsdl from")
-# op.add_option("-u", "--url",
-# action="store", dest="url", default=None, type="string",
-# help="URL to load wsdl from")
op.add_option("-a", "--address",
action="store_true", dest="address", default=False,
help="ws-addressing support, must include WS-Addressing schema.")
-# op.add_option("-e", "--extended",
-# action="store_true", dest="extended", default=False,
-# help="Extended code generation.")
op.add_option("-d", "--debug",
action="callback", callback=SetDebugCallback,
help="debug output")
@@ -301,14 +189,60 @@
sys.exit(os.EX_USAGE)
reader = WSDLTools.WSDLReader()
- if os.path.isfile(args[0]):
- wsdl = reader.loadFromFile(args[0])
+ if isfile(args[0]):
+ _wsdl2dispatch(options, reader.loadFromFile(args[0]))
+ return
+
+ _wsdl2dispatch(options, reader.loadFromURL(args[0]))
+
+
+def _wsdl2py(options, wsdl):
+ if options.simple_naming:
+ # Use a different client suffix
+ # WriteServiceModule.client_module_suffix = "_client"
+ # Write messages definitions to a separate file.
+ #wsdl2pyServiceDescription.separate_messages = True
+ # Use more simple type and element class names
+ containers.SetTypeNameFunc( lambda n: '%s_' %(NC_to_CN(n)) )
+ containers.SetElementNameFunc( lambda n: '%s' %(NC_to_CN(n)) )
+ # Don't add "_" to the attribute name (remove when --aname works well)
+ containers.ContainerBase.func_aname = lambda instnc,n: TextProtect(str(n))
+ # write out the modules with their names rather than their number.
+ utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
+
+ files = []
+ append = files.append
+ if isinstance(wsdl, XMLSchema.XMLSchema):
+ wsm = WriteServiceModule(_XMLSchemaAdapter(wsdl.location, wsdl),
+ addressing=options.address)
else:
- wsdl = reader.loadFromURL(args[0])
+ wsm = WriteServiceModule(wsdl, addressing=options.address)
+ client_mod = wsm.getClientModuleName()
+ client_file = join(options.output_dir, '%s.py' %client_mod)
+ append(client_file)
+ fd = open(client_file, 'w+')
- return _wsdl2dispatch(options, wsdl)
+ # simple naming writes the messages to a separate file
+ if not options.simple_naming:
+ wsm.writeClient(fd)
+ else: # provide a separate file to store messages to.
+ msg_fd = open(join(options.output_dir,
+ '%s.py' %(wsm.getMessagesModuleName()), 'w+' ))
+ wsm.writeClient(fd, msg_fd=msg_fd)
+ msg_fd.close()
+
+ fd.close()
+ types_mod = wsm.getTypesModuleName()
+ types_file = join(options.output_dir, '%s.py' %types_mod)
+ append(types_file)
+ fd = open( join(options.output_dir, '%s.py' %types_mod), 'w+' )
+ wsm.writeTypes(fd)
+ fd.close()
+ return files
+
+
def _wsdl2dispatch(options, wsdl):
if options.simple_naming:
ServiceDescription.server_module_suffix = '_interface'
@@ -317,23 +251,30 @@
# use module names rather than their number.
utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)
-
- ss = None
if options.address is True:
-# if options.extended:
-# ss = DelAuthServiceDescriptionWSA(do_extended=options.extended)
-# else:
- ss = ServiceDescriptionWSA()
+ ss = ServiceDescriptionWSA()
else:
-# if options.extended:
-# ss = DelAuthServiceDescription(do_extended=options.extended)
-# else:
- ss = ServiceDescription()
+ ss = ServiceDescription()
ss.fromWSDL(wsdl)
- module_name = ss.getServiceModuleName()+'.py'
- fd = open( os.path.join(options.output_dir, module_name), 'w+')
+ file_name = ss.getServiceModuleName()+'.py'
+ fd = open( join(options.output_dir, file_name), 'w+')
ss.write(fd)
-
- return module_name
fd.close()
+
+ return file_name
+
+
+class _XMLSchemaAdapter:
+ """Adapts an obj XMLSchema.XMLSchema to look like a WSDLTools.WSDL,
+ just setting a couple attributes code expects to see.
+ """
+ def __init__(self, location, schema):
+ """Parameters:
+ location -- base location, file path
+ schema -- XMLSchema instance
+ """
+ self.name = '_'.join(split(location)[-1].split('.'))
+ self.types = {schema.targetNamespace:schema}
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-14 06:49:33
|
Revision: 1395
http://svn.sourceforge.net/pywebsvcs/?rev=1395&view=rev
Author: boverhof
Date: 2007-06-13 23:49:35 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
M logging.py
-- little fix
Modified Paths:
--------------
trunk/wstools/logging.py
Modified: trunk/wstools/logging.py
===================================================================
--- trunk/wstools/logging.py 2007-06-14 06:37:47 UTC (rev 1394)
+++ trunk/wstools/logging.py 2007-06-14 06:49:35 UTC (rev 1395)
@@ -193,7 +193,7 @@
"""
import os
- if not bool( os.environ.get('GRIDLOG_ON', False) ):
+ if not bool( int(os.environ.get('GRIDLOG_ON', 0)) ):
return
url = os.environ.get('GRIDLOG_DEST')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-14 06:37:45
|
Revision: 1394
http://svn.sourceforge.net/pywebsvcs/?rev=1394&view=rev
Author: boverhof
Date: 2007-06-13 23:37:47 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
M logging.py
-- add processID to log messages
Modified Paths:
--------------
trunk/wstools/logging.py
Modified: trunk/wstools/logging.py
===================================================================
--- trunk/wstools/logging.py 2007-06-12 18:45:39 UTC (rev 1393)
+++ trunk/wstools/logging.py 2007-06-14 06:37:47 UTC (rev 1394)
@@ -5,7 +5,7 @@
#
"""Logging"""
ident = "$Id$"
-import sys
+import os, sys
WARN = 1
DEBUG = 2
@@ -134,6 +134,7 @@
def __init__(self, date=None, **kw):
kw['ts'] = date or self.GLDate()
+ kw['gid'] = kw.get('gid') or os.getpid()
dict.__init__(self, kw)
def __str__(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-12 18:45:37
|
Revision: 1393
http://svn.sourceforge.net/pywebsvcs/?rev=1393&view=rev
Author: boverhof
Date: 2007-06-12 11:45:39 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
M twisted/WSresource.py
-- erased some comments
A twisted/interfaces.py
-- move some stuff out of WSresource,
use these handlers for wsgi, etc
Modified Paths:
--------------
trunk/zsi/ZSI/twisted/WSresource.py
Added Paths:
-----------
trunk/zsi/ZSI/twisted/interfaces.py
Modified: trunk/zsi/ZSI/twisted/WSresource.py
===================================================================
--- trunk/zsi/ZSI/twisted/WSresource.py 2007-06-08 21:59:37 UTC (rev 1392)
+++ trunk/zsi/ZSI/twisted/WSresource.py 2007-06-12 18:45:39 UTC (rev 1393)
@@ -190,33 +190,19 @@
if debug:
log.msg('\t%s handler: %s' %(arg, h), debug=1)
log.msg('\thandler callback: %s' %h.processRequest)
- #arg = h.processRequest(arg, **kw)
d.addCallback(h.processRequest, **kw)
- #return self.handlercb.processRequest(arg, **kw)
d.addCallback(self.handlercb.processRequest, **kw)
reactor.callLater(.0001, d.callback, arg)
- #return d
-
- #def processResponse(self, arg, **kw):
- #from twisted.internet.defer import Deferred
-
- #debug = self.debug
+
if debug: log.msg('===>DEFER PROCESS RESPONSE: %s' %str(arg), debug=1)
- #if arg is None:
- # return d
+
for h in self.handlers:
if debug: log.msg('\t%s handler: %s' %(arg, h), debug=1)
- #arg = h.processResponse(arg, **kw)
d.addCallback(h.processResponse, **kw)
-
- #s = str(arg)
- #if debug: log.msg(s, debug=1)
- #return s
-
- # convert SoapWriter into a string
+
d.addCallback(str)
return d
Added: trunk/zsi/ZSI/twisted/interfaces.py
===================================================================
--- trunk/zsi/ZSI/twisted/interfaces.py (rev 0)
+++ trunk/zsi/ZSI/twisted/interfaces.py 2007-06-12 18:45:39 UTC (rev 1393)
@@ -0,0 +1,124 @@
+###########################################################################
+# Joshua R. Boverhof, LBNL
+# See Copyright for copyright notice!
+# $Id: WSresource.py 1287 2006-10-30 23:04:17Z feanor420 $
+###########################################################################
+
+import sys, warnings
+
+# twisted & related imports
+from zope.interface import classProvides, implements, Interface
+from twisted.python import log
+
+# ZSI imports
+from ZSI import EvaluateException, ParseException, ParsedSoap, SoapWriter
+
+
+#
+# Stability: Unstable
+#
+
+def CheckInputArgs(*interfaces):
+ """Must provide at least one interface, the last one may be repeated.
+ """
+ l = len(interfaces)
+ def wrapper(func):
+ def check_args(self, *args, **kw):
+ for i in range(len(args)):
+ if (l > i and interfaces[i].providedBy(args[i])) or interfaces[-1].providedBy(args[i]):
+ continue
+ if l > i: raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[i])
+ raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[-1])
+ func(self, *args, **kw)
+ return check_args
+ return wrapper
+
+
+class HandlerChainInterface(Interface):
+
+ def processRequest(self, input, **kw):
+ """returns a representation of the request, the
+ last link in the chain must return a response
+ pyobj with a typecode attribute.
+ Parameters:
+ input --
+ Keyword Parameters:
+ request -- HTTPRequest instance
+ resource -- Resource instance
+ """
+ def processResponse(self, output, **kw):
+ """returns a string representing the soap response.
+ Parameters
+ output --
+ Keyword Parameters:
+ request -- HTTPRequest instance
+ resource -- Resource instance
+ """
+
+class CallbackChainInterface(Interface):
+
+ def processRequest(self, input, **kw):
+ """returns a response pyobj with a typecode
+ attribute.
+ Parameters:
+ input --
+ Keyword Parameters:
+ request -- HTTPRequest instance
+ resource -- Resource instance
+ """
+
+class DataHandler:
+ """
+ class variables:
+ readerClass -- factory class to create reader for ParsedSoap instances.
+ writerClass -- ElementProxy implementation to use for SoapWriter instances.
+ """
+ classProvides(HandlerChainInterface)
+ readerClass = None
+ writerClass = None
+
+ @classmethod
+ def processRequest(cls, input, **kw):
+ return ParsedSoap(input, readerclass=cls.readerClass)
+
+ @classmethod
+ def processResponse(cls, output, **kw):
+ sw = SoapWriter(outputclass=cls.writerClass)
+ sw.serialize(output)
+ return sw
+
+
+class DefaultHandlerChain:
+
+ @CheckInputArgs(CallbackChainInterface, HandlerChainInterface)
+ def __init__(self, cb, *handlers):
+ self.handlercb = cb
+ self.handlers = handlers
+ self.debug = len(log.theLogPublisher.observers) > 0
+
+ def processRequest(self, arg, **kw):
+ debug = self.debug
+ if debug: log.msg('--->PROCESS REQUEST: %s' %arg, debug=1)
+
+ for h in self.handlers:
+ if debug: log.msg('\t%s handler: %s' %(arg, h), debug=1)
+ arg = h.processRequest(arg, **kw)
+
+ return self.handlercb.processRequest(arg, **kw)
+
+ def processResponse(self, arg, **kw):
+ debug = self.debug
+ if debug: log.msg('===>PROCESS RESPONSE: %s' %str(arg), debug=1)
+
+ if arg is None:
+ return
+
+ for h in self.handlers:
+ if debug: log.msg('\t%s handler: %s' %(arg, h), debug=1)
+ arg = h.processResponse(arg, **kw)
+
+ s = str(arg)
+ if debug: log.msg(s, debug=1)
+
+ return s
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-08 21:59:36
|
Revision: 1392
http://svn.sourceforge.net/pywebsvcs/?rev=1392&view=rev
Author: boverhof
Date: 2007-06-08 14:59:37 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
M test/test_callhome.py
A ZSI/twisted/wsgi.py
M ZSI/twisted/__init__.py
M ZSI/twisted/WSresource.py
-- moving some stuff around, like to use soap handler stuff for all WSGI
-- Added a "DeferHandlerChain" for twisted,
did some minor refactoring to "render_POST" in order to support it, doesn't affect existing apps.
This will add all soap "handler" callbacks into a Deferred, thus returning control to the reactor
before processing the soap request/response messages.
To use this processing model just set appropriate chain factory protocol
from ZSI.twisted.WSresource import *
DefaultHandlerChainFactory.protocol = DeferHandlerChain
WSAddressHandlerChainFactory.protocol = DeferHandlerChain
WSSecurityHandlerChainFactory
WSResource.factory = DefaultHandlerChainFactory
# or
WSResource.factory = WSAddressHandlerChainFactory
# or
WSResource.factory =
Modified Paths:
--------------
trunk/zsi/ZSI/twisted/WSresource.py
trunk/zsi/ZSI/twisted/__init__.py
trunk/zsi/test/test_callhome.py
Added Paths:
-----------
trunk/zsi/ZSI/twisted/wsgi.py
Modified: trunk/zsi/ZSI/twisted/WSresource.py
===================================================================
--- trunk/zsi/ZSI/twisted/WSresource.py 2007-06-08 21:31:45 UTC (rev 1391)
+++ trunk/zsi/ZSI/twisted/WSresource.py 2007-06-08 21:59:37 UTC (rev 1392)
@@ -24,65 +24,13 @@
from ZSI.address import Address
from ZSI.ServiceContainer import WSActionException
+from interfaces import CheckInputArgs, HandlerChainInterface, CallbackChainInterface,\
+ DataHandler, DefaultHandlerChain
+
#
# Stability: Unstable
-#
-
-class HandlerChainInterface(Interface):
-
- def processRequest(self, input, **kw):
- """returns a representation of the request, the
- last link in the chain must return a response
- pyobj with a typecode attribute.
- Parameters:
- input --
- Keyword Parameters:
- request -- HTTPRequest instance
- resource -- Resource instance
- """
- def processResponse(self, output, **kw):
- """returns a string representing the soap response.
- Parameters
- output --
- Keyword Parameters:
- request -- HTTPRequest instance
- resource -- Resource instance
- """
-
-class CallbackChainInterface(Interface):
-
- def processRequest(self, input, **kw):
- """returns a response pyobj with a typecode
- attribute.
- Parameters:
- input --
- Keyword Parameters:
- request -- HTTPRequest instance
- resource -- Resource instance
- """
-
-class DataHandler:
- """
- class variables:
- readerClass -- factory class to create reader for ParsedSoap instances.
- writerClass -- ElementProxy implementation to use for SoapWriter instances.
- """
- classProvides(HandlerChainInterface)
- readerClass = None
- writerClass = None
-
- @classmethod
- def processRequest(cls, input, **kw):
- return ParsedSoap(input, readerclass=cls.readerClass)
-
- @classmethod
- def processResponse(cls, output, **kw):
- sw = SoapWriter(outputclass=cls.writerClass)
- sw.serialize(output)
- return sw
-
-
+#
class DefaultCallbackHandler:
classProvides(CallbackChainInterface)
@@ -218,26 +166,12 @@
raise
return rsp_pyobj
+
-
-def CheckInputArgs(*interfaces):
- """Must provide at least one interface, the last one may be repeated.
+class DeferHandlerChain:
+ """Each handler is
"""
- l = len(interfaces)
- def wrapper(func):
- def check_args(self, *args, **kw):
- for i in range(len(args)):
- if (l > i and interfaces[i].providedBy(args[i])) or interfaces[-1].providedBy(args[i]):
- continue
- if l > i: raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[i])
- raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[-1])
- func(self, *args, **kw)
- return check_args
- return wrapper
-
-class DefaultHandlerChain:
-
@CheckInputArgs(CallbackChainInterface, HandlerChainInterface)
def __init__(self, cb, *handlers):
self.handlercb = cb
@@ -245,31 +179,51 @@
self.debug = len(log.theLogPublisher.observers) > 0
def processRequest(self, arg, **kw):
- if self.debug:
- log.msg('--->PROCESS REQUEST\n%s' %arg, debug=1)
-
+ from twisted.internet import reactor
+ from twisted.internet.defer import Deferred
+
+ debug = self.debug
+ if debug: log.msg('--->DEFER PROCESS REQUEST: %s' %arg, debug=1)
+
+ d = Deferred()
for h in self.handlers:
- arg = h.processRequest(arg, **kw)
+ if debug:
+ log.msg('\t%s handler: %s' %(arg, h), debug=1)
+ log.msg('\thandler callback: %s' %h.processRequest)
+ #arg = h.processRequest(arg, **kw)
+ d.addCallback(h.processRequest, **kw)
- return self.handlercb.processRequest(arg, **kw)
+ #return self.handlercb.processRequest(arg, **kw)
+ d.addCallback(self.handlercb.processRequest, **kw)
+ reactor.callLater(.0001, d.callback, arg)
+ #return d
- def processResponse(self, arg, **kw):
- if self.debug:
- log.msg('===>PROCESS RESPONSE: %s' %str(arg), debug=1)
+ #def processResponse(self, arg, **kw):
+ #from twisted.internet.defer import Deferred
+
+ #debug = self.debug
+ if debug: log.msg('===>DEFER PROCESS RESPONSE: %s' %str(arg), debug=1)
- if arg is None:
- return
-
+ #if arg is None:
+ # return d
+
for h in self.handlers:
- arg = h.processResponse(arg, **kw)
+ if debug: log.msg('\t%s handler: %s' %(arg, h), debug=1)
+ #arg = h.processResponse(arg, **kw)
+ d.addCallback(h.processResponse, **kw)
- s = str(arg)
- if self.debug:
- log.msg(s, debug=1)
+ #s = str(arg)
+ #if debug: log.msg(s, debug=1)
+ #return s
+
+ # convert SoapWriter into a string
+ d.addCallback(str)
+ return d
+
+ def processResponse(self, arg, **kw):
+ return arg
- return s
-
class DefaultHandlerChainFactory:
protocol = DefaultHandlerChain
@@ -285,8 +239,8 @@
def newInstance(cls):
return cls.protocol(WSAddressCallbackHandler, DataHandler,
WSAddressHandler())
-
+
class WSResource(twisted.web.resource.Resource, object):
"""
class variables:
@@ -302,7 +256,7 @@
"""
twisted.web.resource.Resource.__init__(self)
- def _writeResponse(self, request, response, status=200):
+ def _writeResponse(self, response, request, status=200):
"""
request -- request message
response --- response message
@@ -318,38 +272,32 @@
request.setHeader("Content-Length", str(len(response)))
request.write(response)
request.finish()
- return NOT_DONE_YET
- def _writeFault(self, request, ex):
+ def _writeFault(self, fail, request):
"""
+ fail -- failure
request -- request message
ex -- Exception
"""
- response = None
- response = fault.FaultFromException(ex, False, sys.exc_info()[2]).AsSOAP()
- log.err('SOAP FAULT: %s' % response)
- return self._writeResponse(request, response, status=500)
+ response = fault.FaultFromException(fail.value, False, fail.tb).AsSOAP()
+ self._writeResponse(response, request, status=500)
def render_POST(self, request):
"""Dispatch Method called by twisted render, creates a
request/response handler chain.
request -- twisted.web.server.Request
"""
+ from twisted.internet.defer import maybeDeferred
+
chain = self.factory.newInstance()
data = request.content.read()
- try:
- pyobj = chain.processRequest(data, request=request, resource=self)
- except Exception, ex:
- return self._writeFault(request, ex)
+
+ d = maybeDeferred(chain.processRequest, data, request=request, resource=self)
+ d.addCallback(chain.processResponse, request=request, resource=self)
+ d.addCallback(self._writeResponse, request)
+ d.addErrback(self._writeFault, request)
+
+ return NOT_DONE_YET
- try:
- soap = chain.processResponse(pyobj, request=request, resource=self)
- except Exception, ex:
- return self._writeFault(request, ex)
- if soap is not None:
- return self._writeResponse(request, soap)
- request.finish()
- return NOT_DONE_YET
-
Modified: trunk/zsi/ZSI/twisted/__init__.py
===================================================================
--- trunk/zsi/ZSI/twisted/__init__.py 2007-06-08 21:31:45 UTC (rev 1391)
+++ trunk/zsi/ZSI/twisted/__init__.py 2007-06-08 21:59:37 UTC (rev 1392)
@@ -4,4 +4,5 @@
# $Id$
###########################################################################
-__all__=['WSresource', 'WSsecurity']
+__all__=['interfaces', 'client', 'WSresource', 'WSsecurity']
+import interfaces
\ No newline at end of file
Added: trunk/zsi/ZSI/twisted/wsgi.py
===================================================================
--- trunk/zsi/ZSI/twisted/wsgi.py (rev 0)
+++ trunk/zsi/ZSI/twisted/wsgi.py 2007-06-08 21:59:37 UTC (rev 1392)
@@ -0,0 +1,186 @@
+############################################################################
+# Joshua R. Boverhof, LBNL
+# See Copyright for copyright notice!
+# $Id: __init__.py 1132 2006-02-17 01:55:41Z boverhof $
+###########################################################################
+import os, sys, warnings
+from StringIO import StringIO
+
+# twisted & related imports
+from zope.interface import classProvides, implements, Interface
+from twisted.python import log, failure
+#from twisted.web.error import NoResource
+#from twisted.web.server import NOT_DONE_YET
+#import twisted.web.http
+#import twisted.web.resource
+
+# ZSI imports
+from ZSI import _get_element_nsuri_name, EvaluateException, ParseException
+from ZSI import fault, ParsedSoap, SoapWriter
+
+
+# WS-Address related imports
+from ZSI.address import Address
+
+
+class WSAddressException(Exception):
+ """
+ """
+
+from ZSI.twisted.interfaces import HandlerChainInterface, CallbackChainInterface,\
+ DataHandler, CheckInputArgs, DefaultHandlerChain
+
+
+
+class DefaultCallbackHandler:
+ classProvides(CallbackChainInterface)
+
+ @classmethod
+ def processRequest(cls, ps, **kw):
+ """invokes callback that should return a (request,response) tuple.
+ representing the SOAP request and response respectively.
+ ps -- ParsedSoap instance representing HTTP Body.
+ request -- twisted.web.server.Request
+ """
+ #env = kw['env']
+ #start_response = kw['start_response']
+ resource = kw['resource']
+ #request = kw['request']
+ method = getattr(resource, 'soap_%s' %
+ _get_element_nsuri_name(ps.body_root)[-1])
+
+ try:
+ req_pyobj,rsp_pyobj = method(ps)
+ except TypeError, ex:
+ log.err(
+ 'ERROR: service %s is broken, method MUST return request, response'\
+ % cls.__name__
+ )
+ raise
+ except Exception, ex:
+ log.err('failure when calling bound method')
+ raise
+
+ return rsp_pyobj
+
+
+class DefaultHandlerChainFactory:
+ protocol = DefaultHandlerChain
+
+ @classmethod
+ def newInstance(cls):
+ return cls.protocol(DefaultCallbackHandler, DataHandler)
+
+
+
+class WSGIApplication(dict):
+ encoding = "UTF-8"
+
+ def __call__(self, env, start_response):
+ """do dispatching, else process
+ """
+ script = env['SCRIPT_NAME'] # consumed
+ ipath = os.path.split(env['PATH_INFO'])[1:]
+ for i in range(1, len(ipath)+1):
+ path = os.path.join(*ipath[:i])
+ print "PATH: ", path
+ application = self.get(path)
+ if application is not None:
+ env['SCRIPT_NAME'] = script + path
+ env['PATH_INFO'] = ''
+ print "SCRIPT: ", env['SCRIPT_NAME']
+ return application(env, start_response)
+
+ return self._request_cb(env, start_response)
+
+ def _request_cb(self, env, start_response):
+ """callback method, override
+ """
+ start_response("404 ERROR", [('Content-Type','text/plain')])
+ return ['Move along people, there is nothing to see to hear']
+
+
+class SOAPApplication(WSGIApplication):
+ """
+ """
+ factory = DefaultHandlerChainFactory
+ soapAction = {}
+ root = {}
+
+ def __init__(self, **kw):
+ dict.__init__(self, **kw)
+ self.delegate = None
+
+ def _request_cb(self, env, start_response):
+ """process request,
+ """
+ if env['REQUEST_METHOD'] == 'GET':
+ return self._handle_GET(env, start_response)
+
+ if env['REQUEST_METHOD'] == 'POST':
+ return self._handle_POST(env, start_response)
+
+ start_response("500 ERROR", [('Content-Type','text/plain')])
+ s = StringIO()
+ h = env.items(); h.sort()
+ for k,v in h:
+ print >>s, k,'=',`v`
+ return [s.getvalue()]
+
+ def _handle_GET(self, env, start_response):
+ if env['QUERY_STRING'].lower() == 'wsdl':
+ start_response("200 OK", [('Content-Type','text/plain')])
+ return ['NO WSDL YET']
+
+ start_response("404 ERROR", [('Content-Type','text/plain')])
+ return ['NO RESOURCE FOR GET']
+
+ def _handle_POST(self, env, start_response):
+ """Dispatch Method called by twisted render, creates a
+ request/response handler chain.
+ request -- twisted.web.server.Request
+ """
+ input = env['wsgi.input']
+ data = input.read( int(env['CONTENT_LENGTH']) )
+ mimeType = "text/xml"
+ if self.encoding is not None:
+ mimeType = 'text/xml; charset="%s"' % self.encoding
+
+ request = None
+ resource = self.delegate or self
+ chain = self.factory.newInstance()
+ try:
+ pyobj = chain.processRequest(data, request=request, resource=resource)
+ except Exception, ex:
+ start_response("500 ERROR", [('Content-Type',mimeType)])
+ return [fault.FaultFromException(ex, False, sys.exc_info()[2]).AsSOAP()]
+
+ try:
+ soap = chain.processResponse(pyobj, request=request, resource=resource)
+ except Exception, ex:
+ start_response("500 ERROR", [('Content-Type',mimeType)])
+ return [fault.FaultFromException(ex, False, sys.exc_info()[2]).AsSOAP()]
+
+ start_response("200 OK", [('Content-Type',mimeType)])
+ return [soap]
+
+
+def test(app, port=8080, host="localhost"):
+ """
+ """
+ import sys
+ from twisted.internet import reactor
+ from twisted.python import log
+ from twisted.web2.channel import HTTPFactory
+ from twisted.web2.server import Site
+ from twisted.web2.wsgi import WSGIResource
+
+ log.startLogging(sys.stdout)
+ reactor.listenTCP(port,
+ HTTPFactory( Site(WSGIResource(app)) ),
+ interface=host,
+ )
+ reactor.run()
+
+
+
Modified: trunk/zsi/test/test_callhome.py
===================================================================
--- trunk/zsi/test/test_callhome.py 2007-06-08 21:31:45 UTC (rev 1391)
+++ trunk/zsi/test/test_callhome.py 2007-06-08 21:59:37 UTC (rev 1392)
@@ -4,7 +4,7 @@
from ZSI.wstools.logging import gridLog
os.environ['GRIDLOG_ON'] = '1'
-os.environ['GRIDLOG_DEST'] = "gridlog-udp://portnoy.lbl.gov:15100"
+os.environ['GRIDLOG_DEST'] = "gridlog-udp://netlogger.lbl.gov:15100"
class TestCase(unittest.TestCase):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-08 21:31:42
|
Revision: 1391
http://svn.sourceforge.net/pywebsvcs/?rev=1391&view=rev
Author: boverhof
Date: 2007-06-08 14:31:45 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
M XMLSchema.py
-- if can't find targetNamespace return '' as default
Modified Paths:
--------------
trunk/wstools/XMLSchema.py
Modified: trunk/wstools/XMLSchema.py
===================================================================
--- trunk/wstools/XMLSchema.py 2007-06-08 21:31:09 UTC (rev 1390)
+++ trunk/wstools/XMLSchema.py 2007-06-08 21:31:45 UTC (rev 1391)
@@ -533,10 +533,10 @@
parent = self
targetNamespace = 'targetNamespace'
tns = self.attributes.get(targetNamespace)
- while not tns:
+ while not tns and parent and parent._parent is not None:
parent = parent._parent()
tns = parent.attributes.get(targetNamespace)
- return tns
+ return tns or ''
def getAttributeDeclaration(self, attribute):
"""attribute -- attribute with a QName value (eg. type).
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-08 21:31:08
|
Revision: 1390
http://svn.sourceforge.net/pywebsvcs/?rev=1390&view=rev
Author: boverhof
Date: 2007-06-08 14:31:09 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
M ServiceProxy.py
-- fixed a few bugs with rpc style, added some functions for dealing with schemas. so you can take a schema
out of a message, and use it to parse the rest or the message or subsequent messages.
M TC.py
M generate/containers.py
-- fixed a couple issues with empty namespaces, also need related checkin for wstools
M generate/commands.py
-- little bug, replace all "." with "_" when creating file names not just 1...
Modified Paths:
--------------
trunk/zsi/ZSI/ServiceProxy.py
trunk/zsi/ZSI/TC.py
trunk/zsi/ZSI/generate/commands.py
trunk/zsi/ZSI/generate/containers.py
Modified: trunk/zsi/ZSI/ServiceProxy.py
===================================================================
--- trunk/zsi/ZSI/ServiceProxy.py 2007-06-05 05:46:46 UTC (rev 1389)
+++ trunk/zsi/ZSI/ServiceProxy.py 2007-06-08 21:31:09 UTC (rev 1390)
@@ -32,7 +32,8 @@
def __init__(self, wsdl, url=None, service=None, port=None, tracefile=None,
nsdict=None, transport=None, transdict=None,
- cachedir='.service_proxy_dir', asdict=True):
+ cachedir=os.path.join(os.path.expanduser('~'), '.zsi_service_proxy_dir'),
+ asdict=True):
"""
Parameters:
wsdl -- URL of WSDL.
@@ -63,6 +64,7 @@
self._port = self._service.ports[port or 0]
self._name = self._service.name
self._methods = {}
+ self._cachedir = cachedir
# Set up rpc methods for service/port
port = self._port
@@ -70,11 +72,24 @@
portType = binding.getPortType()
for port in self._service.ports:
for item in port.getPortType().operations:
- callinfo = wstools.WSDLTools.callInfoFromWSDL(port, item.name)
+ try:
+ callinfo = wstools.WSDLTools.callInfoFromWSDL(port, item.name)
+ except:
+ # ignore non soap-1.1 bindings
+ continue
+
method = MethodProxy(self, callinfo)
setattr(self, item.name, method)
self._methods.setdefault(item.name, []).append(method)
+ self._mod = self._load(wsdl)
+
+ def _load(self, location):
+ """
+ location -- URL or file location
+ isxsd -- is this a xsd file?
+ """
+ cachedir = self._cachedir
# wsdl2py: deal with XML Schema
if not os.path.isdir(cachedir): os.mkdir(cachedir)
@@ -86,119 +101,196 @@
except IOError:
del cp; cp = None
- option = wsdl.replace(':', '-') # colons seem to screw up option
+ option = location.replace(':', '-') # colons seem to screw up option
if (cp is not None and cp.has_section(section) and
cp.has_option(section, option)):
types = cp.get(section, option)
else:
# dont do anything to anames
containers.ContainerBase.func_aname = lambda instnc,n: str(n)
- files = commands.wsdl2py(['-o', cachedir, wsdl])
+ files = commands.wsdl2py(['-o', cachedir, location])
if cp is None: cp = ConfigParser()
if not cp.has_section(section): cp.add_section(section)
-
types = filter(lambda f: f.endswith('_types.py'), files)[0]
cp.set(section, option, types)
cp.write(open(file, 'w'))
if os.path.abspath(cachedir) not in sys.path:
sys.path.append(os.path.abspath(cachedir))
-
+
mod = os.path.split(types)[-1].rstrip('.py')
- self._mod = __import__(mod)
-
- def _call(self, name, soapheaders, *args, **kwargs):
- """Call the named remote web service method."""
- if len(args) and len(kwargs):
- raise TypeError(
- 'Use positional or keyword argument only.'
- )
-
- callinfo = getattr(self, name).callinfo
-
- # go through the list of defined methods, and look for the one with
- # the same number of arguments as what was passed. this is a weak
- # check that should probably be improved in the future to check the
- # types of the arguments to allow for polymorphism
- for method in self._methods[name]:
- if len(method.callinfo.inparams) == len(kwargs):
- callinfo = method.callinfo
-
- binding = _Binding(tracefile=self._tracefile,
- url=self._url or callinfo.location,
- nsdict=self._nsdict,
- soapaction=callinfo.soapAction)
-
-
- if len(kwargs): args = kwargs
-
- kw = dict(unique=True)
- if callinfo.use == 'encoded':
- kw['unique'] = False
-
- if callinfo.style == 'rpc':
- request = TC.Struct(None, ofwhat=[],
- pname=(callinfo.namespace, name), **kw)
+ return __import__(mod)
+
+ def _load_schema(self, location, xml=None):
+ """
+ location -- location of schema, also used as a key
+ xml -- optional string representation of schema
+ """
+ cachedir = self._cachedir
+ # wsdl2py: deal with XML Schema
+ if not os.path.isdir(cachedir): os.mkdir(cachedir)
+
+ file = os.path.join(cachedir, '.cache')
+ section = 'TYPES'
+ cp = ConfigParser()
+ try:
+ cp.readfp(open(file, 'r'))
+ except IOError:
+ del cp; cp = None
- response = TC.Struct(None, ofwhat=[],
- pname=(callinfo.namespace, name+"Response"), **kw)
+ option = location.replace(':', '-') # colons seem to screw up option
+ if (cp is not None and cp.has_section(section) and
+ cp.has_option(section, option)):
+ types = cp.get(section, option)
+ else:
+ # dont do anything to anames
+ containers.ContainerBase.func_aname = lambda instnc,n: str(n)
+ from ZSI.wstools import XMLSchema
- if len(callinfo.getInParameters()) != len(args):
- raise RuntimeError('expecting "%s" parts, got %s' %(
- str(callinfo.getInParameters(), str(args))))
- for msg,pms in ((request,callinfo.getInParameters()),
- (response,callinfo.getOutParameters())):
- msg.ofwhat = []
- for part in pms:
- klass = GTD(*part.type)
- if klass is None:
- if part.type:
- klass = filter(lambda gt: part.type==gt.type,TC.TYPES)
- if len(klass) == 0:
- klass = filter(lambda gt: part.type[1]==gt.type[1],TC.TYPES)
- if not len(klass):klass = [TC.Any]
- if len(klass) > 1: #Enumerations, XMLString, etc
- klass = filter(lambda i: i.__dict__.has_key('type'), klass)
- klass = klass[0]
- else:
- klass = TC.Any
+ reader = XMLSchema.SchemaReader(base_url=location)
+ if xml is not None and isinstance(xml, basestring):
+ schema = reader.loadFromString(xml)
+ elif xml is not None:
+ raise RuntimeError, 'Unsupported: XML must be string'
+ elif not os.path.isfile(location):
+ schema = reader.loadFromURL(location)
+ else:
+ schema = reader.reader.loadFromFile(location)
- msg.ofwhat.append(klass(part.name))
+ # TODO: change this to keyword list
+ class options:
+ output_dir = cachedir
+ schema = True
+ simple_naming = False
+ address = False
+ schema.location = location
+ files = commands._wsdl2py(options, schema)
+ if cp is None: cp = ConfigParser()
+ if not cp.has_section(section): cp.add_section(section)
+ types = filter(lambda f: f.endswith('_types.py'), files)[0]
+ cp.set(section, option, types)
+ cp.write(open(file, 'w'))
+
+ if os.path.abspath(cachedir) not in sys.path:
+ sys.path.append(os.path.abspath(cachedir))
+
+ mod = os.path.split(types)[-1].rstrip('.py')
+ return __import__(mod)
+
+ def _call(self, name, soapheaders):
+ """return the Call to the named remote web service method.
+ closure used to prevent multiple values for name and soapheaders
+ parameters
+ """
+
+ def call_closure(*args, **kwargs):
+ """Call the named remote web service method."""
+ if len(args) and len(kwargs):
+ raise TypeError, 'Use positional or keyword argument only.'
+
+ if len(args) > 0:
+ raise TypeError, 'Not supporting SOAPENC:Arrays or XSD:List'
+
+ if len(kwargs):
+ args = kwargs
+
+ callinfo = getattr(self, name).callinfo
+
+ # go through the list of defined methods, and look for the one with
+ # the same number of arguments as what was passed. this is a weak
+ # check that should probably be improved in the future to check the
+ # types of the arguments to allow for polymorphism
+ for method in self._methods[name]:
+ if len(method.callinfo.inparams) == len(kwargs):
+ callinfo = method.callinfo
+
+ binding = _Binding(tracefile=self._tracefile,
+ url=self._url or callinfo.location,
+ nsdict=self._nsdict,
+ soapaction=callinfo.soapAction)
+
+ kw = dict(unique=True)
+ if callinfo.use == 'encoded':
+ kw['unique'] = False
+
+ if callinfo.style == 'rpc':
+ request = TC.Struct(None, ofwhat=[],
+ pname=(callinfo.namespace, name), **kw)
+
+ response = TC.Struct(None, ofwhat=[],
+ pname=(callinfo.namespace, name+"Response"), **kw)
+
+ if len(callinfo.getInParameters()) != len(args):
+ raise RuntimeError('expecting "%s" parts, got %s' %(
+ str(callinfo.getInParameters(), str(args))))
+
+ for msg,pms in ((request,callinfo.getInParameters()),
+ (response,callinfo.getOutParameters())):
+ msg.ofwhat = []
+ for part in pms:
+ klass = GTD(*part.type)
+ if klass is None:
+ if part.type:
+ klass = filter(lambda gt: part.type==gt.type,TC.TYPES)
+ if len(klass) == 0:
+ klass = filter(lambda gt: part.type[1]==gt.type[1],TC.TYPES)
+ if not len(klass):klass = [TC.Any]
+ if len(klass) > 1: #Enumerations, XMLString, etc
+ klass = filter(lambda i: i.__dict__.has_key('type'), klass)
+ klass = klass[0]
+ else:
+ klass = TC.Any
- msg.ofwhat = tuple(msg.ofwhat)
- if not args: args = {}
- else:
- # Grab <part element> attribute
- ipart,opart = callinfo.getInParameters(),callinfo.getOutParameters()
- if ( len(ipart) != 1 or not ipart[0].element_type or
- ipart[0].type is None ):
- raise RuntimeError, 'Bad Input Message "%s"' %callinfo.name
+ msg.ofwhat.append(klass(part.name))
+
+ msg.ofwhat = tuple(msg.ofwhat)
+ if not args: args = {}
+ else:
+ # Grab <part element> attribute
+ ipart,opart = callinfo.getInParameters(),callinfo.getOutParameters()
+ if ( len(ipart) != 1 or not ipart[0].element_type or
+ ipart[0].type is None ):
+ raise RuntimeError, 'Bad Input Message "%s"' %callinfo.name
+
+ if ( len(opart) not in (0,1) or not opart[0].element_type or
+ opart[0].type is None ):
+ raise RuntimeError, 'Bad Output Message "%s"' %callinfo.name
+
+# if ( len(args) > 1 ):
+# raise RuntimeError, 'Message has only one part: %s' %str(args)
+
+ ipart = ipart[0]
+ request,response = GED(*ipart.type),None
+ if opart: response = GED(*opart[0].type)
- if ( len(opart) not in (0,1) or not opart[0].element_type or
- opart[0].type is None ):
- raise RuntimeError, 'Bad Output Message "%s"' %callinfo.name
+ msg = args
+ if self._asdict:
+ if not msg: msg = dict()
+ self._nullpyclass(request)
+ elif request.pyclass is not None:
+ if type(args) is dict:
+ msg = request.pyclass()
+ msg.__dict__.update(args)
+ elif type(args) is list and len(args) == 1:
+ msg = request.pyclass(args[0])
+ else:
+ msg = request.pyclass()
+
+ binding.Send(None, None, msg,
+ requesttypecode=request,
+ soapheaders=soapheaders,
+ encodingStyle=callinfo.encodingStyle)
- if ( len(args) != 1 ):
- raise RuntimeError, 'Message has only one part'
+ if response is None:
+ return None
- ipart = ipart[0]
- request,response = GED(*ipart.type),None
- if opart: response = GED(*opart[0].type)
+ if self._asdict: self._nullpyclass(response)
+ return binding.Receive(replytype=response,
+ encodingStyle=callinfo.encodingStyle)
+
+ return call_closure
- if self._asdict: self._nullpyclass(request)
- binding.Send(None, None, args,
- requesttypecode=request,
- soapheaders=soapheaders,
- encodingStyle=callinfo.encodingStyle)
-
- if response is None:
- return None
-
- if self._asdict: self._nullpyclass(response)
- return binding.Receive(replytype=response,
- encodingStyle=callinfo.encodingStyle)
-
def _nullpyclass(cls, typecode):
typecode.pyclass = None
if not hasattr(typecode, 'ofwhat'): return
@@ -219,7 +311,7 @@
self.soapheaders = []
def __call__(self, *args, **kwargs):
- return self.parent()._call(self.__name__, self.soapheaders, *args, **kwargs)
+ return self.parent()._call(self.__name__, self.soapheaders)(*args, **kwargs)
def add_headers(self, **headers):
"""packing dicts into typecode pyclass, may fail if typecodes are
Modified: trunk/zsi/ZSI/TC.py
===================================================================
--- trunk/zsi/ZSI/TC.py 2007-06-05 05:46:46 UTC (rev 1389)
+++ trunk/zsi/ZSI/TC.py 2007-06-08 21:31:09 UTC (rev 1390)
@@ -234,7 +234,7 @@
elt -- the DOM element being parsed
'''
return self.pname == elt.localName and \
- self.nspname in [None, elt.namespaceURI]
+ self.nspname in [None, '', elt.namespaceURI]
def nilled(self, elt, ps):
'''Is the element NIL, and is that okay?
Modified: trunk/zsi/ZSI/generate/commands.py
===================================================================
--- trunk/zsi/ZSI/generate/commands.py 2007-06-05 05:46:46 UTC (rev 1389)
+++ trunk/zsi/ZSI/generate/commands.py 2007-06-08 21:31:09 UTC (rev 1390)
@@ -61,7 +61,7 @@
else:
tmp = fname.split('.')
- f.name = tmp[0] + '_' + tmp[1]
+ f.name = '_'.join(tmp)
f.types = { schemaObj.targetNamespace : schemaObj }
return f
Modified: trunk/zsi/ZSI/generate/containers.py
===================================================================
--- trunk/zsi/ZSI/generate/containers.py 2007-06-05 05:46:46 UTC (rev 1389)
+++ trunk/zsi/ZSI/generate/containers.py 2007-06-08 21:31:09 UTC (rev 1390)
@@ -275,7 +275,7 @@
# - namespace utility methods
def getNSAlias(self):
- if self.ns:
+ if self.ns is not None:
return NAD.getAlias(self.ns)
raise ContainerError, 'no self.ns attr defined in %s' % self.__class__
@@ -987,11 +987,17 @@
'Struct(pname=("%(nspname)s","%(pname)s"), ofwhat=%(ofwhat)s, pyclass=%(pyclass)s, encoded="%(encoded)s")'
message = ['class %(pyclass)s:',
- '%(ID1)sdef __init__(self):']
+ '%(ID1)sdef __init__(self, **kw):',
+ '%(ID2)s"""Keyword parameters:',
+ ]
- for aname in tcb.getAttributeNames():
- message.append('%(ID2)sself.' + aname +' = None')
- message.append('%(ID2)sreturn')
+ idx = len(message)
+ for a,p in zip(tcb.getAttributeNames(), tcb.getParameterNames()):
+ message.insert(idx, '%(ID2)s' + p + ' -- part ' + p)
+ message.append('%(ID2)sself.' + a + ' = kw.get("%s")' %p)
+ idx += 1
+
+ message.insert(idx, '%(ID2)s"""')
# TODO: This isn't a TypecodeContainerBase instance but it
# certaintly generates a pyclass and typecode.
@@ -1071,12 +1077,18 @@
'Struct(pname=("%(nspname)s","%(pname)s"), ofwhat=%(ofwhat)s, pyclass=%(pyclass)s, encoded="%(encoded)s")'
message = ['class %(pyclass)s:',
- '%(ID1)sdef __init__(self):']
+ '%(ID1)sdef __init__(self, **kw):',
+ '%(ID2)s"""Keyword parameters:',
+ ]
+
+ idx = len(message)
+ for a,p in zip(tcb.getAttributeNames(), tcb.getParameterNames()):
+ message.insert(idx, '%(ID2)s' + p + ' -- part ' + p)
+ message.append('%(ID2)sself.' + a + ' = kw.get("%s")' %p)
+ idx += 1
+
+ message.insert(idx, '%(ID2)s"""')
- for aname in tcb.getAttributeNames():
- message.append('%(ID2)sself.' + aname +' = None')
- message.append('%(ID2)sreturn')
-
# TODO: This isn't a TypecodeContainerBase instance but it
# certaintly generates a pyclass and typecode.
#if self.metaclass is None:
@@ -1786,6 +1798,12 @@
'''
return map(lambda e: self.getAttributeName(e.name), self.tcListElements)
+ def getParameterNames(self):
+ '''returns a list of pnames representing the parts
+ of the message.
+ '''
+ return map(lambda e: e.name, self.tcListElements)
+
def setParts(self, parts):
self.mgContent = parts
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-05 05:46:45
|
Revision: 1389
http://svn.sourceforge.net/pywebsvcs/?rev=1389&view=rev
Author: boverhof
Date: 2007-06-04 22:46:46 -0700 (Mon, 04 Jun 2007)
Log Message:
-----------
M logging.py
Modified Paths:
--------------
trunk/wstools/logging.py
Modified: trunk/wstools/logging.py
===================================================================
--- trunk/wstools/logging.py 2007-06-05 04:48:41 UTC (rev 1388)
+++ trunk/wstools/logging.py 2007-06-05 05:46:46 UTC (rev 1389)
@@ -105,7 +105,7 @@
end: Immediately after the last action in a task (that succeeded).
error: an error condition that does not correspond to an end event.
- date -- timestamp
+ ts -- timestamp
level -- logging level (see levels below)
status -- integer status code
gid -- global grid identifier
@@ -116,10 +116,10 @@
More info: http://www.cedps.net/wiki/index.php/LoggingBestPractices#Python
reserved -- list of reserved names,
- omitname -- list of reserved names, output only values ('date', 'event',)
+ omitname -- list of reserved names, output only values ('ts', 'event',)
levels -- dict of levels and description
"""
- reserved = ('date', 'event', 'level', 'status', 'gid', 'prog')
+ reserved = ('ts', 'event', 'level', 'status', 'gid', 'prog')
omitname = ()
levels = dict(FATAL='Component cannot continue, or system is unusable.',
ALERT='Action must be taken immediately.',
@@ -133,7 +133,7 @@
)
def __init__(self, date=None, **kw):
- kw['date'] = date or self.GLDate()
+ kw['ts'] = date or self.GLDate()
dict.__init__(self, kw)
def __str__(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-05 04:48:41
|
Revision: 1388
http://svn.sourceforge.net/pywebsvcs/?rev=1388&view=rev
Author: boverhof
Date: 2007-06-04 21:48:41 -0700 (Mon, 04 Jun 2007)
Log Message:
-----------
M test/wsdl2py/test_EchoWSAddr200403.py
M test/wsdl2py/servers/EchoServer.py
M test/test_t4.py
M test/test_t5.py
_M ZSI
M ZSI/__init__.py
M ZSI/TC.py
M ZSI/parse.py
M ZSI/TCcompound.py
M ZSI/writer.py
M ZSI/address.py
-- fixed basic ws-addressing, pass EPR's around
Modified Paths:
--------------
branches/zsi-element-tree/ZSI/TC.py
branches/zsi-element-tree/ZSI/TCcompound.py
branches/zsi-element-tree/ZSI/__init__.py
branches/zsi-element-tree/ZSI/address.py
branches/zsi-element-tree/ZSI/parse.py
branches/zsi-element-tree/test/wsdl2py/servers/EchoServer.py
branches/zsi-element-tree/test/wsdl2py/test_EchoWSAddr200403.py
Added Paths:
-----------
branches/zsi-element-tree/ZSI/elementtreeproxy.py
Modified: branches/zsi-element-tree/ZSI/TC.py
===================================================================
--- branches/zsi-element-tree/ZSI/TC.py 2007-06-04 21:56:51 UTC (rev 1387)
+++ branches/zsi-element-tree/ZSI/TC.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -10,7 +10,8 @@
_find_xmlns_prefix, _get_element_nsuri_name, _get_idstr, \
EvaluateException, \
_valid_encoding, ParseException
-
+
+from lxml import etree
from ZSI.wstools.Namespaces import SCHEMA, SOAP
#from ZSI.wstools.Utility import SplitQName
#from ZSI.wstools.c14n import Canonicalize
@@ -26,6 +27,7 @@
except ImportError:
from StringIO import StringIO
+_is_etree_element = lambda E: type(E) is etree._Element
_is_xsd_or_soap_ns = lambda ns: ns in [
SCHEMA.XSD3, SOAP.ENC, SCHEMA.XSD1, SCHEMA.XSD2, ]
@@ -207,8 +209,6 @@
elt -- the DOM element being parsed
ps -- the ParsedSoap object.
'''
- print "ELT: ", elt
- print "PS: ", ps
# attr = _find_type(elt)
# if attr is None:
# return (None,None)
@@ -283,8 +283,6 @@
# in [ _Node.TEXT_NODE, _Node.CDATA_SECTION_NODE ]])
# ElementTree: need to strip??
- print "ELT: ", elt
- print "TEXT: ", elt.text
return elt.text
def parse_attributes(self, elt, ps):
@@ -581,7 +579,8 @@
ps.Backtrace(elt))
elt = ps.FindLocalHREF(href, elt)
(ns,type) = self.checktype(elt, ps)
- if not type and elt.namespaceURI == SOAP.ENC:
+ #if not type and elt.namespaceURI == SOAP.ENC:
+ if not type and _get_element_nsuri_name(elt)[0] == SOAP.ENC:
ns,type = SOAP.ENC, elt.localName
if not type or (ns,type) == (SOAP.ENC,'Array'):
if self.aslist or _find_arraytype(elt):
@@ -1422,7 +1421,12 @@
raise TypeError, 'pyobj is a typecode instance.'
what = getattr(pyobj, 'typecode', None)
- if what is not None and type(pyobj) is types.InstanceType:
+ if what is None and _is_etree_element(pyobj):
+ e = elt._etree
+ e.append(pyobj)
+ return
+
+ if what is None and type(pyobj) is types.InstanceType:
tc = pyobj.__class__
what = Any.serialmap.get(tc)
if not what:
@@ -1479,13 +1483,16 @@
what.typed = True
return pyobj
- if skip:
- what = XML(pname=(nspname,pname), wrapped=False)
- elif self.processContents == 'lax':
- what = Any(pname=(nspname,pname), unique=True)
- else:
- what = Any(pname=(nspname,pname), unique=True)
+ #if skip:
+ # what = XML(pname=(nspname,pname), wrapped=False)
+ #elif self.processContents == 'lax':
+ # what = Any(pname=(nspname,pname), unique=True)
+ #else:
+ # what = Any(pname=(nspname,pname), unique=True)
+ if what is None:
+ return elt
+
try:
pyobj = what.parse(elt, ps)
except EvaluateException, ex:
Modified: branches/zsi-element-tree/ZSI/TCcompound.py
===================================================================
--- branches/zsi-element-tree/ZSI/TCcompound.py 2007-06-04 21:56:51 UTC (rev 1387)
+++ branches/zsi-element-tree/ZSI/TCcompound.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -198,6 +198,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
@@ -229,37 +232,38 @@
if self.inorder is True and i == j:
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):
- raise EvaluateException('Element "' + what.aname + \
- '" missing from complexType', ps.Backtrace(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):
+# 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 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
+#
+# 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))
- 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
Modified: branches/zsi-element-tree/ZSI/__init__.py
===================================================================
--- branches/zsi-element-tree/ZSI/__init__.py 2007-06-04 21:56:51 UTC (rev 1387)
+++ branches/zsi-element-tree/ZSI/__init__.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -300,8 +300,6 @@
# )
# lxml ElementTree API Extension
- print prefix
- print E.nsmap
return E.nsmap[prefix]
Modified: branches/zsi-element-tree/ZSI/address.py
===================================================================
--- branches/zsi-element-tree/ZSI/address.py 2007-06-04 21:56:51 UTC (rev 1387)
+++ branches/zsi-element-tree/ZSI/address.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -186,11 +186,12 @@
ReferenceProperties = getattr(endPointReference, '_ReferenceProperties', None)
if ReferenceProperties is not None:
for v in getattr(ReferenceProperties, '_any', ()):
- if not hasattr(v,'typecode'):
- raise EvaluateException, '<any> element, instance missing typecode attribute'
+ #if not hasattr(v,'typecode'):
+ # raise EvaluateException, '<any> element, instance missing typecode attribute'
pyobjs.append(v)
+
self.header_pyobjs = tuple(pyobjs)
def setResponseFromWSAddress(self, address, localURL):
@@ -224,7 +225,10 @@
'''
for pyobj in self.header_pyobjs:
if hasattr(pyobj, 'typecode') is False:
- raise RuntimeError, 'all header pyobjs must have a typecode attribute'
+ #raise RuntimeError, 'all header pyobjs must have a typecode attribute'
+ # TODO: Assuming I know this is EPR/ReferenceParameters/any
+ sw.serialize_header(pyobj, typecode=AnyElement(), **kw)
+ continue
sw.serialize_header(pyobj, **kw)
Added: branches/zsi-element-tree/ZSI/elementtreeproxy.py
===================================================================
--- branches/zsi-element-tree/ZSI/elementtreeproxy.py (rev 0)
+++ branches/zsi-element-tree/ZSI/elementtreeproxy.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -0,0 +1,116 @@
+############################################################################
+# Joshua R. Boverhof, LBNL
+# See Copyright for copyright notice!
+###########################################################################
+#from Ft.Xml.Domlette import NonvalidatingReaderBase, NonvalidatingReader
+#from ZSI.wstools.c14n import Canonicalize
+from ZSI.wstools.Namespaces import SCHEMA, XMLNS
+#from ZSI.wstools.Utility import DOMException
+from ZSI.wstools.Utility import MessageInterface
+
+#from xml.etree import ElementTree
+from lxml import etree as ElementTree
+
+#class DomletteReader(NonvalidatingReaderBase):
+# '''Used with ZSI.parse.ParsedSoap
+# '''
+# fromString = NonvalidatingReaderBase.parseString
+# fromStream = NonvalidatingReaderBase.parseStream
+
+class ElementProxyException(Exception):
+ '''TODO: Should probably rename DOMException ElementProxyException.
+ '''
+
+class ElementTreeProxy(MessageInterface):
+ '''ElementTree wrapper
+ TODO: add c14n for message signatures, issue with "getPrefix"
+ '''
+
+ def __init__(self, sw, message=None):
+ '''Initialize.
+ sw -- SoapWriter
+ '''
+ assert message is None, 'TODO'
+ self._etree = None
+
+ def __str__(self):
+ return self.toString()
+
+ def toString(self):
+ return ElementTree.tostring(self._etree)
+
+ #############################################
+ #Methods used in TypeCodes
+ #############################################
+ def createAppendElement(self, namespaceURI, localName, prefix=None):
+ '''Create a new element (namespaceURI,name), append it
+ to current node, and return the newly created node.
+ Keyword arguments:
+ namespaceURI -- namespace of element to create
+ localName -- local name of new element
+ prefix -- if namespaceURI is not defined, declare prefix. defaults
+ to 'ns1' if left unspecified.
+ '''
+ assert prefix is None, 'TODO: can really do this'
+ e = ElementTree.Element("{%s}%s" %(namespaceURI, localName))
+ self._etree.append(e)
+
+ eproxy = ElementTreeProxy(None)
+ eproxy._etree = e
+ return eproxy
+
+ def createAppendTextNode(self, pyobj):
+ '''TODO: obviously mixed text content cannot be accurately
+ represented via this interface. Only 1 possible text node/element
+ '''
+ self._etree.text = pyobj
+
+ def createDocument(self, namespaceURI, localName):
+ self._etree = ElementTree.Element('{%s}%s' %(namespaceURI, localName))
+
+ def getElement(self, namespaceURI, localName):
+ for e in self._etree.getchildren():
+ l = e.tag.strip('{').split('}')
+ if not namespaceURI:
+ if len(l) == 1 and l[0] == localName:
+ eproxy = ElementTreeProxy(None)
+ eproxy._etree = e
+ return eproxy
+ elif len(l) == 2 and l[0] == namespaceURI and l[1] == localName:
+ eproxy = ElementTreeProxy(None)
+ eproxy._etree = e
+ return eproxy
+
+ raise ElementProxyException,\
+ 'No such element(%s,%s)' %(namespaceURI,localName)
+
+ def getPrefix(self, namespaceURI):
+ '''TODO: this is not possible w/elementTree since namespace prefix
+ mappings aren't done until serialization. completely abstraced out.
+ '''
+ raise NotImplementedError, 'this func isnt going to work'
+
+ def setAttributeNS(self, namespaceURI, localName, value):
+ '''
+ Keyword arguments:
+ namespaceURI -- namespace of attribute to create, None is for
+ attributes in no namespace.
+ localName -- local name of new attribute
+ value -- value of new attribute
+ '''
+ self._etree.attrib["{%s}%s" %(namespaceURI, localName)] = value
+
+ def setAttributeType(self, namespaceURI, localName):
+ '''xsi:type attribute, value must be a QName
+ '''
+ self.setAttributeNS(SCHEMA.XSI3, 'type',
+ ElementTree.QName('{%s}%s' %(namespaceURI,localName))
+ )
+
+ def setNamespaceAttribute(self, prefix, namespaceURI):
+ '''TODO: Not sure how to force this to be used by ElementTree
+ Keyword arguments:
+ prefix -- xmlns prefix
+ namespaceURI -- value of prefix
+ '''
+ self._etree.attrib["xmlns:%s" %prefix] = namespaceURI
Modified: branches/zsi-element-tree/ZSI/parse.py
===================================================================
--- branches/zsi-element-tree/ZSI/parse.py 2007-06-04 21:56:51 UTC (rev 1387)
+++ branches/zsi-element-tree/ZSI/parse.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -13,7 +13,7 @@
import types
from ZSI.wstools.Namespaces import SOAP, XMLNS
-from ZSI.wstools.Utility import SplitQName
+#from ZSI.wstools.Utility import SplitQName
#_find_actor = lambda E: E.getAttributeNS(SOAP.ENV, "actor") or None
#_find_mu = lambda E: E.getAttributeNS(SOAP.ENV, "mustUnderstand")
@@ -103,9 +103,6 @@
# raise ParseException('Document has "' + elt.localName + \
# '" element, not Envelope', 0)
if _get_element_nsuri_name(elt) != (SOAP.ENV, "Envelope"):
- print "X: ", _get_element_nsuri_name(elt) != (SOAP.ENV, "Envelope")
- print "A: ",_get_element_nsuri_name(elt)
- print "V: ",(SOAP.ENV, "Envelope")
raise ParseException('Document has "' + \
str(_get_element_nsuri_name(elt)) + \
'" element, not Envelope', 0)
@@ -388,11 +385,11 @@
v = []
occurs = 0
namespaceURI,tagName = 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] is not None]:
# prefix,name = SplitQName(c_elt.tagName)
# nsuri = _resolve_prefix(c_elt, prefix)
# if tagName == name and namespaceURI == nsuri:
- if _get_element_nsuri_name(c_elt) == (nsuri, name):
+ if _get_element_nsuri_name(c_elt) == (namespaceURI,tagName):
pyobj = what.parse(c_elt, self)
else:
continue
Modified: branches/zsi-element-tree/test/wsdl2py/servers/EchoServer.py
===================================================================
--- branches/zsi-element-tree/test/wsdl2py/servers/EchoServer.py 2007-06-04 21:56:51 UTC (rev 1387)
+++ branches/zsi-element-tree/test/wsdl2py/servers/EchoServer.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -5,6 +5,8 @@
###########################################################################
import sys
from ZSI.ServiceContainer import AsServer
+from ZSI.wstools.logging import setBasicLoggerDEBUG
+setBasicLoggerDEBUG()
from EchoServer_server import EchoServer
"""
@@ -18,7 +20,7 @@
class Service(EchoServer):
def soap_Echo(self, ps):
response = EchoServer.soap_Echo(self, ps)
- response.EchoResult = self.request.EchoIn
+ response.EchoResult = self.request.EchoIn or "NO ECHO??"
return response
Modified: branches/zsi-element-tree/test/wsdl2py/test_EchoWSAddr200403.py
===================================================================
--- branches/zsi-element-tree/test/wsdl2py/test_EchoWSAddr200403.py 2007-06-04 21:56:51 UTC (rev 1387)
+++ branches/zsi-element-tree/test/wsdl2py/test_EchoWSAddr200403.py 2007-06-05 04:48:41 UTC (rev 1388)
@@ -5,7 +5,7 @@
###########################################################################
import os, sys, unittest
from ServiceTest import main, ServiceTestCase, ServiceTestSuite
-from ZSI import FaultException, TC
+from ZSI import ParsedSoap, FaultException, TC
from ZSI.schema import GED, GTD
"""
@@ -55,10 +55,27 @@
kw['wsAddressURI'] = 'http://schemas.xmlsoap.org/ws/2004/03/addressing'
return kw
- def test_local_Echo(self):
+ def Xtest_local_Echo(self):
msg = self.client_module.EchoRequest()
rsp = self.client_module.EchoResponse()
+ def test_local_EPR(self):
+ MSG = """
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"><soapenv:Header><wsa:MessageID soapenv:mustUnderstand="0">uuid:61f126b0-12ef-11dc-9fd4-a15ae8e2e52b</wsa:MessageID><wsa:To soapenv:mustUnderstand="0">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:To><wsa:Action soapenv:mustUnderstand="0">http://counter.com/CounterPortType/createCounterResponse</wsa:Action><wsa:From soapenv:mustUnderstand="0"><wsa:Address>http://192.168.15.4:8080/wsrf/services/CounterService</wsa:Address></wsa:From><wsa:RelatesTo RelationshipType="wsa:Reply" soapenv:mustUnderstand="0">uuid:1180998026.34</wsa:RelatesTo></soapenv:Header><soapenv:Body>
+ <wsa:EndpointReference>
+ <wsa:Address>http://192.168.15.4:8080/wsrf/services/CounterService</wsa:Address>
+ <wsa:ReferenceProperties><CounterKey>21201606</CounterKey></wsa:ReferenceProperties>
+ <wsa:ReferenceParameters/>
+ </wsa:EndpointReference>
+</soapenv:Body></soapenv:Envelope>
+"""
+ ps = ParsedSoap(MSG)
+ pyobj = ps.Parse( GED('http://schemas.xmlsoap.org/ws/2004/03/addressing','EndpointReference') )
+ print "PYOBJ: ", pyobj
+ print "\t", pyobj.Address
+ print "\t", pyobj.ReferenceProperties
+ print "\t", pyobj.ReferenceProperties.Any
+
def test_dispatch_Echo(self):
loc = self.client_module.EchoWSAddr200403ServerLocator()
port = loc.getport(**self.getPortKWArgs())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bov...@us...> - 2007-06-04 21:56:50
|
Revision: 1387
http://svn.sourceforge.net/pywebsvcs/?rev=1387&view=rev
Author: boverhof
Date: 2007-06-04 14:56:51 -0700 (Mon, 04 Jun 2007)
Log Message:
-----------
M test/test_t4.py
M test/test_t5.py
_M ZSI
M ZSI/__init__.py
M ZSI/TC.py
M ZSI/parse.py
M ZSI/TCcompound.py
M ZSI/writer.py
-- had to change to lxml for parsing xsi:type QName values, several fixes to get more unittests working
Modified Paths:
--------------
branches/zsi-element-tree/ZSI/TC.py
branches/zsi-element-tree/ZSI/TCcompound.py
branches/zsi-element-tree/ZSI/__init__.py
branches/zsi-element-tree/ZSI/parse.py
branches/zsi-element-tree/ZSI/writer.py
branches/zsi-element-tree/test/test_t4.py
branches/zsi-element-tree/test/test_t5.py
Property Changed:
----------------
branches/zsi-element-tree/ZSI/
Property changes on: branches/zsi-element-tree/ZSI
___________________________________________________________________
Name: svn:externals
- wstools https://svn.sourceforge.net/svnroot/pywebsvcs/trunk/wstools
+ wstools https://svn.sourceforge.net/svnroot/pywebsvcs/trunk/wstools
Modified: branches/zsi-element-tree/ZSI/TC.py
===================================================================
--- branches/zsi-element-tree/ZSI/TC.py 2007-06-02 23:26:01 UTC (rev 1386)
+++ branches/zsi-element-tree/ZSI/TC.py 2007-06-04 21:56:51 UTC (rev 1387)
@@ -12,8 +12,8 @@
_valid_encoding, ParseException
from ZSI.wstools.Namespaces import SCHEMA, SOAP
-from ZSI.wstools.Utility import SplitQName
-from ZSI.wstools.c14n import Canonicalize
+#from ZSI.wstools.Utility import SplitQName
+#from ZSI.wstools.c14n import Canonicalize
from ZSI.wstools.logging import getLogger as _GetLogger
import re, types, time, copy
@@ -207,18 +207,26 @@
elt -- the DOM element being parsed
ps -- the ParsedSoap object.
'''
- typeName = _find_type(elt)
- if typeName is None or typeName == "":
+ print "ELT: ", elt
+ print "PS: ", ps
+# attr = _find_type(elt)
+# if attr is None:
+# return (None,None)
+
+# # Parse the QNAME.
+# prefix,typeName = SplitQName(typeName)
+#
+# uri = ps.GetElementNSdict(elt).get(prefix)
+# if uri is None:
+# raise EvaluateException('Malformed type attribute (bad NS)',
+# ps.Backtrace(elt))
+
+ prefix,typeName = _find_type(elt)
+ if typeName is None:
return (None,None)
- # Parse the QNAME.
- prefix,typeName = SplitQName(typeName)
- uri = ps.GetElementNSdict(elt).get(prefix)
- if uri is None:
- raise EvaluateException('Malformed type attribute (bad NS)',
- ps.Backtrace(elt))
-
- #typeName = list[1]
+ uri = _resolve_prefix(elt, prefix)
+
parselist,errorlist = self.get_parse_and_errorlist()
if not parselist or \
(uri,typeName) in parselist or \
@@ -260,7 +268,7 @@
'''
if not _valid_encoding(elt):
raise EvaluateException('Invalid encoding', ps.Backtrace(elt))
- c = _children(elt)
+ c = _child_elements(elt)
if mixed is False and len(c):
# if len(c) == 0:
# raise EvaluateException('Value missing', ps.Backtrace(elt))
@@ -277,7 +285,7 @@
# ElementTree: need to strip??
print "ELT: ", elt
print "TEXT: ", elt.text
- return elt.text.strip()
+ return elt.text
def parse_attributes(self, elt, ps):
'''find all attributes specified in the attribute_typecode_dict in
@@ -414,6 +422,7 @@
def parse(self, elt, ps):
self.checkname(elt, ps)
+ elt.text is None
if len(_children(elt)) == 0:
href = _find_href(elt)
if not href:
@@ -433,7 +442,8 @@
elt = ps.FindLocalHREF(href, elt)
self.checktype(elt, ps)
if self.nilled(elt, ps): return Nilled
- if len(_children(elt)) == 0:
+# if len(_children(elt)) == 0:
+ if elt.text is None:
v = self.empty_content
else:
v = self.simple_value(elt, ps)
@@ -1364,7 +1374,7 @@
self.nspname,self.pname,nspname,pname), ps.Backtrace(elt))
#locate xsi:type
- prefix, typeName = SplitQName(_find_type(elt))
+ prefix, typeName = _find_type(elt)
namespaceURI = _resolve_prefix(elt, prefix)
pyclass = GTD(namespaceURI, typeName)
if not pyclass:
@@ -1452,7 +1462,7 @@
# Allow use of "<any>" element declarations w/ local
# element declarations
- prefix, typeName = SplitQName(_find_type(elt))
+ prefix, typeName = _find_type(elt)
if not skip and typeName:
namespaceURI = _resolve_prefix(elt, prefix or 'xmlns')
# First look thru user defined namespaces, if don't find
Modified: branches/zsi-element-tree/ZSI/TCcompound.py
===================================================================
--- branches/zsi-element-tree/ZSI/TCcompound.py 2007-06-02 23:26:01 UTC (rev 1386)
+++ branches/zsi-element-tree/ZSI/TCcompound.py 2007-06-04 21:56:51 UTC (rev 1387)
@@ -4,7 +4,7 @@
'''
from ZSI import _copyright, _children, _child_elements, \
- _inttypes, _stringtypes, _seqtypes, _find_arraytype, _find_href, \
+ _inttypes, _stringtypes, _seqtypes, _find_attrNS, _find_arraytype, _find_href, \
_find_type, _find_xmlns_prefix, _get_idstr, EvaluateException, \
ParseException
@@ -152,6 +152,8 @@
elt = ps.FindLocalHREF(href, elt)
c = _child_elements(elt)
count = len(c)
+ print "COUNT: ", count
+ print "CHILD: ", c
if self.nilled(elt, ps): return Nilled
# Create the object.
@@ -184,10 +186,13 @@
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 j,c_elt in [ (j, c[j]) for j in crange if c[j] is not None]:
+ self.logger.debug("CELT: (%s,%s)", j, c_elt)
# Parse value, and mark this one done.
if debug:
- self.logger.debug("child node: (%s,%s)", c_elt.namespaceURI, c_elt.tagName)
+ #self.logger.debug("child node: (%s,%s)", c_elt.namespaceURI, c_elt.tagName)
+ self.logger.debug("child node: %s" %c_elt)
match = False
if what.name_match(c_elt):
Modified: branches/zsi-element-tree/ZSI/__init__.py
===================================================================
--- branches/zsi-element-tree/ZSI/__init__.py 2007-06-02 23:26:01 UTC (rev 1386)
+++ branches/zsi-element-tree/ZSI/__init__.py 2007-06-04 21:56:51 UTC (rev 1387)
@@ -167,7 +167,7 @@
# if n.nodeType == _Node.ELEMENT_NODE ]
_attrs = lambda ET: ET.attrib.values()
-_children = lambda ET: [] + ET.getchildren() + [ET.text] #ETREE: No logical equivalent?
+_children = lambda ET: [c for c in [] + ET.getchildren() + [ET.text] if c is not None] #ETREE: No logical equivalent?
_child_elements = lambda ET: ET.getchildren()
##
@@ -243,8 +243,13 @@
or _find_attrNS(ET, _SCHEMA.XSI1, attr) \
or _find_attrNS(ET, _SCHEMA.XSI2, attr)
-_find_type = lambda E: _find_xsi_attr(E, "type")
+def _find_type(E):
+ prefix,value = None, _find_xsi_attr(E, "type")
+ if value is not None and value.find(':') >= 0:
+ prefix,value = value.split(':')
+ return prefix,value
+
#_find_xmlns_prefix = lambda E, attr: E.getAttributeNS(_XMLNS.BASE, attr)
#_find_default_namespace = lambda E: E.getAttributeNS(_XMLNS.BASE, None)
_find_xmlns_prefix = lambda ET, attr: _find_attrNS(_XMLNS.BASE, attr)
@@ -269,7 +274,7 @@
'ElementTree API: Irrelevant'
)
-def _resolve_prefix(celt, prefix):
+def _resolve_prefix(E, prefix):
'''resolve prefix to a namespaceURI. If None or
empty str, return default namespace or None.
@@ -289,10 +294,17 @@
# if prefix:
# raise EvaluateException, 'cant resolve xmlns:%s' %prefix
# return namespaceURI
- raise NotImplementedError(
- "ElementTree API Extension ???"
- )
+
+# raise NotImplementedError(
+# "ElementTree API Extension ???"
+# )
+
+ # lxml ElementTree API Extension
+ print prefix
+ print E.nsmap
+ return E.nsmap[prefix]
+
def _valid_encoding(elt):
'''Does this node have a valid encoding?
'''
Modified: branches/zsi-element-tree/ZSI/parse.py
===================================================================
--- branches/zsi-element-tree/ZSI/parse.py 2007-06-02 23:26:01 UTC (rev 1386)
+++ branches/zsi-element-tree/ZSI/parse.py 2007-06-04 21:56:51 UTC (rev 1387)
@@ -2,8 +2,10 @@
# $Header$
'''SOAP messaging parsing.
'''
-from xml import etree
-from xml.etree import ElementTree
+
+from lxml import etree
+from lxml.etree import ElementTree
+
from ZSI import _copyright, _children, _attrs, _child_elements, _stringtypes, \
_backtrace, EvaluateException, ParseException, _valid_encoding, \
_find_attr, _resolve_prefix, _get_element_nsuri_name
@@ -39,7 +41,7 @@
data_elements -- list of non-root elements in the SOAP Body
trailer_elements -- list of elements following the SOAP body
'''
- defaultReaderClass = staticmethod(ElementTree.XML)
+ defaultReaderClass = staticmethod(etree.XML)
def __init__(self, input, readerclass=None, keepdom=False,
trailers=False, resolver=None, envelope=True, **kw):
Modified: branches/zsi-element-tree/ZSI/writer.py
===================================================================
--- branches/zsi-element-tree/ZSI/writer.py 2007-06-02 23:26:01 UTC (rev 1386)
+++ branches/zsi-element-tree/ZSI/writer.py 2007-06-04 21:56:51 UTC (rev 1387)
@@ -34,7 +34,8 @@
nsdict={}, outputclass=None, **kw):
'''Initialize.
'''
- outputclass = outputclass or ElementProxy
+ from ZSI.elementtreeproxy import ElementTreeProxy as ElementTreeProxy
+ outputclass = outputclass or ElementTreeProxy
if not issubclass(outputclass, MessageInterface):
raise TypeError, 'outputclass must subclass MessageInterface'
Modified: branches/zsi-element-tree/test/test_t4.py
===================================================================
--- branches/zsi-element-tree/test/test_t4.py 2007-06-02 23:26:01 UTC (rev 1386)
+++ branches/zsi-element-tree/test/test_t4.py 2007-06-04 21:56:51 UTC (rev 1387)
@@ -45,7 +45,11 @@
# Faulted while processing; now it's the body
print >>OUT, FaultFromException(e, 0, sys.exc_info()[2]).AsSOAP()
self.fail()
- PrettyPrint(dict['xmltest'])
+
+ #PrettyPrint(dict['xmltest'])
+ print
+ print dict['xmltest']
+ print
print '**', dict['stringtest'], '**'
def makeTestSuite():
Modified: branches/zsi-element-tree/test/test_t5.py
===================================================================
--- branches/zsi-element-tree/test/test_t5.py 2007-06-02 23:26:01 UTC (rev 1386)
+++ branches/zsi-element-tree/test/test_t5.py 2007-06-04 21:56:51 UTC (rev 1387)
@@ -3,7 +3,8 @@
from ZSI import *
from ZSI import resolvers
from xml.dom import Node
-#from xml.dom.ext.reader import PyExpat
+from xml.etree import ElementTree
+
try:
import cStringIO as StringIO
except ImportError:
@@ -21,8 +22,8 @@
print 'xml=', xml.getvalue()
for h,b in cid.parts:
print h, b.read()
- dom = PyExpat.Reader().fromStream(xml)
- print dom
+ print ElementTree.XML(xml.getvalue())
+ print xml.getvalue()
def makeTestSuite():
suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fea...@us...> - 2007-06-02 23:26:18
|
Revision: 1386
http://svn.sourceforge.net/pywebsvcs/?rev=1386&view=rev
Author: feanor420
Date: 2007-06-02 16:26:01 -0700 (Sat, 02 Jun 2007)
Log Message:
-----------
Added Tom Uram's patch to give up the ref to the HTTPSConnection object
to avoid a deadlock condition.
Modified Paths:
--------------
branches/m2crypto-branch/zsi/ZSI/client.py
Modified: branches/m2crypto-branch/zsi/ZSI/client.py
===================================================================
--- branches/m2crypto-branch/zsi/ZSI/client.py 2007-05-27 00:54:22 UTC (rev 1385)
+++ branches/m2crypto-branch/zsi/ZSI/client.py 2007-06-02 23:26:01 UTC (rev 1386)
@@ -379,6 +379,7 @@
# Horrible internals hack to patch things up.
self.h._HTTPConnection__state = httplib._CS_REQ_SENT
self.h._HTTPConnection__response = None
+ self.h = None
return self.data
def IsSOAP(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|