Mercurial > libervia-pubsub
comparison 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 |
comparison
equal
deleted
inserted
replaced
205:e6b710bf2b24 | 206:274a45d2a5ab |
---|---|
1 # Copyright (c) 2003-2008 Ralph Meijer | 1 # Copyright (c) 2003-2008 Ralph Meijer |
2 # See LICENSE for details. | 2 # See LICENSE for details. |
3 | 3 |
4 from twisted.application import internet, strports | 4 from twisted.application import internet, service, strports |
5 from twisted.conch import manhole, manhole_ssh | 5 from twisted.conch import manhole, manhole_ssh |
6 from twisted.cred import portal, checkers | 6 from twisted.cred import portal, checkers |
7 from twisted.web2 import channel, resource, server | 7 from twisted.web2 import channel, log, resource, server |
8 from twisted.web2.tap import Web2Service | |
8 | 9 |
9 from idavoll import gateway, tap | 10 from idavoll import gateway, tap |
10 from idavoll.gateway import RemoteSubscriptionService | 11 from idavoll.gateway import RemoteSubscriptionService |
11 | 12 |
12 class Options(tap.Options): | 13 class Options(tap.Options): |
13 optParameters = [ | 14 optParameters = [ |
14 ('webport', None, '8086', 'Web port'), | 15 ('webport', None, '8086', 'Web port'), |
15 ] | 16 ] |
17 | |
16 | 18 |
17 | 19 |
18 def getManholeFactory(namespace, **passwords): | 20 def getManholeFactory(namespace, **passwords): |
19 def getManHole(_): | 21 def getManHole(_): |
20 return manhole.Manhole(namespace) | 22 return manhole.Manhole(namespace) |
24 p = portal.Portal(realm) | 26 p = portal.Portal(realm) |
25 p.registerChecker( | 27 p.registerChecker( |
26 checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords)) | 28 checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords)) |
27 f = manhole_ssh.ConchFactory(p) | 29 f = manhole_ssh.ConchFactory(p) |
28 return f | 30 return f |
31 | |
29 | 32 |
30 | 33 |
31 def makeService(config): | 34 def makeService(config): |
32 s = tap.makeService(config) | 35 s = tap.makeService(config) |
33 | 36 |
65 root.child_unsubscribe = gateway.RemoteUnsubscribeResource(ss) | 68 root.child_unsubscribe = gateway.RemoteUnsubscribeResource(ss) |
66 root.child_items = gateway.RemoteItemsResource(ss) | 69 root.child_items = gateway.RemoteItemsResource(ss) |
67 | 70 |
68 site = server.Site(root) | 71 site = server.Site(root) |
69 w = internet.TCPServer(int(config['webport']), channel.HTTPFactory(site)) | 72 w = internet.TCPServer(int(config['webport']), channel.HTTPFactory(site)) |
73 | |
74 if config["verbose"]: | |
75 logObserver = log.DefaultCommonAccessLoggingObserver() | |
76 w2s = Web2Service(logObserver) | |
77 w.setServiceParent(w2s) | |
78 w = w2s | |
79 | |
70 w.setServiceParent(s) | 80 w.setServiceParent(s) |
71 | 81 |
72 # Set up a manhole | 82 # Set up a manhole |
73 | 83 |
74 namespace = {'service': s, | 84 namespace = {'service': s, |
75 'component': cs, | 85 'component': cs, |
76 'backend': bs} | 86 'backend': bs, |
87 'root': root} | |
88 | |
77 f = getManholeFactory(namespace, admin='admin') | 89 f = getManholeFactory(namespace, admin='admin') |
78 manholeService = strports.service('2222', f) | 90 manholeService = strports.service('2222', f) |
79 manholeService.setServiceParent(s) | 91 manholeService.setServiceParent(s) |
80 | 92 |
81 return s | 93 return s |