comparison idavoll/idavoll.py @ 42:7d088c61e131

Make choice of backend an option to mktap. This includes the database configuration.
author Ralph Meijer <ralphm@ik.nu>
date Sun, 31 Oct 2004 21:12:55 +0000
parents c51bca11699b
children 9685b7e291ef
comparison
equal deleted inserted replaced
41:ea3d3544a52e 42:7d088c61e131
1 from twisted.protocols.jabber import component 1 from twisted.protocols.jabber import component
2 from twisted.application import service 2 from twisted.application import service
3 from twisted.python import components 3 from twisted.python import components
4 import backend 4 import backend
5 import memory_backend
6 import pubsub 5 import pubsub
7 import xmpp_error 6 import xmpp_error
8 7
9 import sys 8 import sys
10 9
86 85
87 # set up Jabber Component 86 # set up Jabber Component
88 sm = component.buildServiceManager(config["jid"], config["secret"], 87 sm = component.buildServiceManager(config["jid"], config["secret"],
89 ("tcp:%s:%s" % (config["rhost"], config["rport"]))) 88 ("tcp:%s:%s" % (config["rhost"], config["rport"])))
90 89
91 b = memory_backend 90 if config['backend'] == 'pgsql':
92 bs = b.BackendService() 91 import pgsql_backend as b
92 st = b.Storage(user=config['dbuser'], database=config['dbname'])
93 bs = b.BackendService(st)
94 elif config['backend'] == 'memory':
95 import memory_backend as b
96 bs = b.BackendService()
97
93 98
94 component.IService(bs).setServiceParent(sm) 99 component.IService(bs).setServiceParent(sm)
95 100
96 bsc = b.PublishService() 101 bsc = b.PublishService()
97 bsc.setServiceParent(bs) 102 bsc.setServiceParent(bs)
99 104
100 bsc = b.NotificationService() 105 bsc = b.NotificationService()
101 bsc.setServiceParent(bs) 106 bsc.setServiceParent(bs)
102 component.IService(bsc).setServiceParent(sm) 107 component.IService(bsc).setServiceParent(sm)
103 108
104 bsc = b.NodeCreationService() 109 if config['backend'] == 'memory':
105 bsc.setServiceParent(bs) 110 bsc = b.NodeCreationService()
106 component.IService(bsc).setServiceParent(sm) 111 bsc.setServiceParent(bs)
112 component.IService(bsc).setServiceParent(sm)
107 113
108 bsc = b.SubscriptionService() 114 bsc = b.SubscriptionService()
109 bsc.setServiceParent(bs) 115 bsc.setServiceParent(bs)
110 component.IService(bsc).setServiceParent(sm) 116 component.IService(bsc).setServiceParent(sm)
111 117
112 s = IdavollService() 118 s = IdavollService()
113 s.setServiceParent(sm) 119 s.setServiceParent(sm)
114 120
115 sm.setServiceParent(serviceCollection) 121 sm.setServiceParent(serviceCollection)