Commit c599f0d0 authored by Vincent Pelletier's avatar Vincent Pelletier

Cache parsed WSDL data, once per thread and for the duration of zope process life.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27221 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e3d05826
......@@ -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
......@@ -158,6 +159,10 @@ class MethodWrapper(object):
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:
"""
Holds a SOAP connection described by a WSDL file.
......@@ -191,8 +196,10 @@ class SOAPWSDLConnection:
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment