Log message for revision 67769:
  Made the twisted module optional.
  

Changed:
  U   Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py

-=-
Modified: 
Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py
===================================================================
--- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py    
2006-04-30 15:59:12 UTC (rev 67768)
+++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py    
2006-04-30 16:13:46 UTC (rev 67769)
@@ -5,11 +5,30 @@
 from re import compile
 from socket import gethostbyaddr
 
-import twisted.internet
-from twisted.application.service import MultiService
-import zope.app.appsetup.interfaces
-import zope.app.twisted.main
+try:
+    import twisted.internet
+    from twisted.application.service import MultiService
+    import zope.app.appsetup.interfaces
+    import zope.app.twisted.main
 
+    import twisted.web2.wsgi
+    import twisted.web2.server
+    import twisted.web2.log
+    
+    try:
+        from twisted.web2.http import HTTPFactory
+    except ImportError:
+        from twisted.web2.channel.http import HTTPFactory
+    
+    from zope.component import provideUtility
+    from zope.app.twisted.server import ServerType, SSLServerType
+    from zope.app.twisted.interfaces import IServerType
+    from ZPublisher.WSGIPublisher import publish_module
+    
+    _use_twisted = True
+except ImportError:
+    _use_twisted = False
+
 # top-level key handlers
 
 
@@ -242,29 +261,15 @@
     if isIp_(host): return [host]
     return gethostbyaddr(host)[2]
 
-# XXX Need to find a better place for this.
 
-import twisted.web2.wsgi
-import twisted.web2.server
-import twisted.web2.log
+# Twisted support:
 
-try:
-    from twisted.web2.http import HTTPFactory
-except ImportError:
-    from twisted.web2.channel.http import HTTPFactory
-
-from zope.component import provideUtility
-from zope.app.twisted.server import ServerType, SSLServerType
-from zope.app.twisted.interfaces import IServerType
-from ZPublisher.WSGIPublisher import publish_module
-
 def createHTTPFactory(ignored):
-    resource = twisted.web2.wsgi.WSGIResource(
-        publish_module)
+    resource = twisted.web2.wsgi.WSGIResource(publish_module)
     resource = twisted.web2.log.LogWrapperResource(resource)
 
     return HTTPFactory(twisted.web2.server.Site(resource))
 
-http = ServerType(createHTTPFactory, 8080)
-
-provideUtility(http, IServerType, 'Zope2-HTTP')
+if _use_twisted:
+    http = ServerType(createHTTPFactory, 8080)
+    provideUtility(http, IServerType, 'Zope2-HTTP')

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to