diff idavoll/tap_http.py @ 206:274a45d2a5ab

Implement root collection that includes all leaf nodes.
author Ralph Meijer <ralphm@ik.nu>
date Mon, 04 Aug 2008 13:47:10 +0000
parents b4bf0a5ce50d
children a321f9300054
line wrap: on
line diff
--- a/idavoll/tap_http.py	Mon Aug 04 07:10:45 2008 +0000
+++ b/idavoll/tap_http.py	Mon Aug 04 13:47:10 2008 +0000
@@ -1,10 +1,11 @@
 # Copyright (c) 2003-2008 Ralph Meijer
 # See LICENSE for details.
 
-from twisted.application import internet, strports
+from twisted.application import internet, service, strports
 from twisted.conch import manhole, manhole_ssh
 from twisted.cred import portal, checkers
-from twisted.web2 import channel, resource, server
+from twisted.web2 import channel, log, resource, server
+from twisted.web2.tap import Web2Service
 
 from idavoll import gateway, tap
 from idavoll.gateway import RemoteSubscriptionService
@@ -15,6 +16,7 @@
     ]
 
 
+
 def getManholeFactory(namespace, **passwords):
     def getManHole(_):
         return manhole.Manhole(namespace)
@@ -28,6 +30,7 @@
     return f
 
 
+
 def makeService(config):
     s = tap.makeService(config)
 
@@ -67,13 +70,22 @@
 
     site = server.Site(root)
     w = internet.TCPServer(int(config['webport']), channel.HTTPFactory(site))
+
+    if config["verbose"]:
+        logObserver = log.DefaultCommonAccessLoggingObserver()
+        w2s = Web2Service(logObserver)
+        w.setServiceParent(w2s)
+        w = w2s
+
     w.setServiceParent(s)
 
     # Set up a manhole
 
     namespace = {'service': s,
                  'component': cs,
-                 'backend': bs}
+                 'backend': bs,
+                 'root': root}
+
     f = getManholeFactory(namespace, admin='admin')
     manholeService = strports.service('2222', f)
     manholeService.setServiceParent(s)