[CalendarServer-changes] [9089] CalendarServer/branches/users/glyph/ipv6-client/twistedcaldav/client /pool.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 13 11:46:53 PDT 2012


Revision: 9089
          http://trac.macosforge.org/projects/calendarserver/changeset/9089
Author:   glyph at apple.com
Date:     2012-04-13 11:46:53 -0700 (Fri, 13 Apr 2012)
Log Message:
-----------
Make 'config' a local import so that it will be used as sparingly as possible.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/ipv6-client/twistedcaldav/client/pool.py

Modified: CalendarServer/branches/users/glyph/ipv6-client/twistedcaldav/client/pool.py
===================================================================
--- CalendarServer/branches/users/glyph/ipv6-client/twistedcaldav/client/pool.py	2012-04-13 18:46:47 UTC (rev 9088)
+++ CalendarServer/branches/users/glyph/ipv6-client/twistedcaldav/client/pool.py	2012-04-13 18:46:53 UTC (rev 9089)
@@ -37,8 +37,6 @@
 from twext.web2.dav.util import allDataFromStream
 from twext.web2.stream import MemoryStream
 
-from twistedcaldav.config import config
-
 class PooledHTTPClientFactory(ClientFactory, LoggingMixIn):
     """
     A client factory for HTTPClient that notifies a pool of it's state. It the connection
@@ -397,16 +395,25 @@
 
 
 
+def _configuredClientContextFactory():
+    """
+    Get a client context factory from the configuration.
+    """
+    from twistedcaldav.config import config
+    return ChainingOpenSSLContextFactory(
+        config.SSLPrivateKey, config.SSLCertificate,
+        certificateChainFile=config.SSLAuthorityChain,
+        sslmethod=getattr(OpenSSL.SSL, config.SSLMethod)
+    )
+
+
+
 def installPool(name, url, maxClients=5, reactor=None):
 
     if reactor is None:
         from twisted.internet import reactor
     parsedURL = urlparse.urlparse(url)
-    ctxf = ChainingOpenSSLContextFactory(
-        config.SSLPrivateKey, config.SSLCertificate,
-        certificateChainFile=config.SSLAuthorityChain,
-        sslmethod=getattr(OpenSSL.SSL, config.SSLMethod)
-    )
+    ctxf = _configuredClientContextFactory()
     pool = HTTPClientPool(
         name,
         parsedURL.scheme,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120413/eab3d6d2/attachment-0001.html>


More information about the calendarserver-changes mailing list