diff sat_pubsub/tap_http.py @ 273:6ba0d6def7f5

Use twisted.web instead of web2, initial tests.
author Ralph Meijer <ralphm@ik.nu>
date Sun, 20 Jan 2013 13:38:41 +0100
parents d55620ceafed
children 002c59dbc23f
line wrap: on
line diff
--- a/sat_pubsub/tap_http.py	Tue Sep 09 08:09:26 2014 +0200
+++ b/sat_pubsub/tap_http.py	Sun Jan 20 13:38:41 2013 +0100
@@ -52,11 +52,10 @@
 
 """
 
-from twisted.application import internet, service, strports
+from twisted.application import internet, strports
 from twisted.conch import manhole, manhole_ssh
 from twisted.cred import portal, checkers
-from twisted.web2 import channel, log, resource, server
-from twisted.web2.tap import Web2Service
+from twisted.web import resource, server
 
 from sat_pubsub import gateway, tap
 from sat_pubsub.gateway import RemoteSubscriptionService
@@ -106,31 +105,21 @@
     root = resource.Resource()
 
     # Set up resources that exposes the backend
-    root.child_create = gateway.CreateResource(bs, config['jid'],
-                                               config['jid'])
-    root.child_delete = gateway.DeleteResource(bs, config['jid'],
-                                               config['jid'])
-    root.child_publish = gateway.PublishResource(bs, config['jid'],
-                                                 config['jid'])
-    root.child_list = gateway.ListResource(bs)
+    root.putChild('create', gateway.CreateResource(bs, config['jid'],
+                                                   config['jid']))
+    root.putChild('delete', gateway.DeleteResource(bs, config['jid'],
+                                                   config['jid']))
+    root.putChild('publish', gateway.PublishResource(bs, config['jid'],
+                                                     config['jid']))
+    root.putChild('list', gateway.ListResource(bs))
 
     # Set up resources for accessing remote pubsub nodes.
-    root.child_subscribe = gateway.RemoteSubscribeResource(ss)
-    root.child_unsubscribe = gateway.RemoteUnsubscribeResource(ss)
-    root.child_items = gateway.RemoteItemsResource(ss)
-
-    if config["verbose"]:
-        root = log.LogWrapperResource(root)
+    root.putChild('subscribe', gateway.RemoteSubscribeResource(ss))
+    root.putChild('unsubscribe', gateway.RemoteUnsubscribeResource(ss))
+    root.putChild('items', gateway.RemoteItemsResource(ss))
 
     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 = internet.TCPServer(int(config['webport']), site)
     w.setServiceParent(s)
 
     # Set up a manhole