[Erp5-report] r27221 - /erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed May 27 18:21:04 CEST 2009
Author: vincent
Date: Wed May 27 18:21:03 2009
New Revision: 27221
URL: http://svn.erp5.org?rev=27221&view=rev
Log:
Cache parsed WSDL data, once per thread and for the duration of zope process life.
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=27221&r1=27220&r2=27221&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ConnectionPlugin/SOAPWSDLConnection.py [utf8] Wed May 27 18:21:03 2009
@@ -29,6 +29,7 @@
import SOAPpy
from Products.AGProjects.patches import SOAPpy_WSDL as WSDL
from AccessControl.SecurityInfo import allow_class, allow_module
+import threading
# Exception class.
# This allows restricted python to handle exceptions without allowing direct
@@ -157,6 +158,10 @@
return self._method(*args, **kw)
except SOAPpy.Types.faultType, exception:
raise SOAPWSDLException(*exception())
+
+# SOAPpy says nothing about thread-safeness of parsed WSDL.
+# Be on the safe side by using threading.local as a storage for it.
+wsdl_cache = threading.local()
class SOAPWSDLConnection:
"""
@@ -191,8 +196,10 @@
self._service = service
def connect(self):
- # TODO: caching of wsdl parsing
- wsdl = SOAPpy.wstools.WSDLTools.WSDLReader().loadFromURL(self.url)
+ try:
+ wsdl = wsdl_cache.parsed
+ except AttributeError:
+ wsdl = wsdl_cache.parsed = SOAPpy.wstools.WSDLTools.WSDLReader().loadFromURL(self.url)
# TODO: transport (http) level authentication using self._user_name and
# self._password
return WSDLConnection(wsdl, self._credentials, self._service)
More information about the Erp5-report
mailing list