[Erp5-report] r27220 - /erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed May 27 18:01:13 CEST 2009
Author: vincent
Date: Wed May 27 18:01:07 2009
New Revision: 27220
URL: http://svn.erp5.org?rev=27220&view=rev
Log:
Wrap SOAP methods in order to intercept & transtype SOAPpy exceptions, to make the API more independant from underlying SOAP library.
Modified:
erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py
Modified: erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py?rev=27220&r1=27219&r2=27220&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py [utf8] Wed May 27 18:01:07 2009
@@ -29,6 +29,35 @@
import SOAPpy
from Products.AGProjects.patches import SOAPpy_WSDL as WSDL
from AccessControl.SecurityInfo import allow_class, allow_module
+
+# Exception class.
+# This allows restricted python to handle exceptions without allowing direct
+# import of SOAPpy module (because it should not have to be dependant from
+# underlying interface API, only this file has to be).
+
+class SOAPWSDLException(Exception):
+
+ __allow_access_to_unprotected_subobjects__ = True
+
+ def __init__(self, code, name, info):
+ self.code = code
+ self.name = name
+ self.info = info
+
+ def getCode(self):
+ return self.code
+
+ def getName(self):
+ return self.name
+
+ def getInfo(self):
+ return self.info
+
+ def __str__(self):
+ return '<%s at 0x%x: %r %r %r>' % (self.__class__.__name__, id(self),
+ self.name, self.code, self.info)
+
+allow_class(SOAPWSDLException)
# Authentication classes.
# These are SOAP authentication classes.
@@ -114,7 +143,20 @@
self._port = port
def __getattr__(self, method_id):
- return getattr(self._port, method_id)
+ return MethodWrapper(getattr(self._port, method_id))
+
+class MethodWrapper(object):
+
+ __allow_access_to_unprotected_subobjects__ = True
+
+ def __init__(self, method):
+ self._method = method
+
+ def __call__(self, *args, **kw):
+ try:
+ return self._method(*args, **kw)
+ except SOAPpy.Types.faultType, exception:
+ raise SOAPWSDLException(*exception())
class SOAPWSDLConnection:
"""
More information about the Erp5-report
mailing list