def __init__(self, backend): PubSubService.__init__(self) self.backend = backend self.hideNodes = False self.pubSubFeatures = self._getPubSubFeatures() self.backend.registerNotifier(self._notify) self.backend.registerPreDelete(self._preDelete)
def makeService(config): s = service.MultiService() # Create backend service with storage if config['backend'] == 'pgsql': from twisted.enterprise import adbapi from idavoll.pgsql_storage import Storage from psycopg2.extras import NamedTupleConnection dbpool = adbapi.ConnectionPool( 'psycopg2', user=config['dbuser'], password=config['dbpass'], database=config['dbname'], host=config['dbhost'], port=config['dbport'], cp_reconnect=True, client_encoding='utf-8', connection_factory=NamedTupleConnection, ) st = Storage(dbpool) elif config['backend'] == 'memory': from idavoll.memory_storage import Storage st = Storage() bs = BackendService(st) bs.setName('backend') bs.setServiceParent(s) # Set up XMPP server-side component with publish-subscribe capabilities cs = Component(config["rhost"], int(config["rport"]), config["jid"].full(), config["secret"]) cs.setName('component') cs.setServiceParent(s) cs.factory.maxDelay = 900 if config["verbose"]: cs.logTraffic = True FallbackHandler().setHandlerParent(cs) VersionHandler('Idavoll', __version__).setHandlerParent(cs) DiscoHandler().setHandlerParent(cs) resource = IPubSubResource(bs) resource.hideNodes = config["hide-nodes"] resource.serviceJID = config["jid"] ps = PubSubService(resource) ps.setHandlerParent(cs) resource.pubsubService = ps return s
def makeService(config): s = service.MultiService() # Create backend service with storage if config['backend'] == 'pgsql': from twisted.enterprise import adbapi from idavoll.pgsql_storage import Storage from psycopg2.extras import NamedTupleConnection dbpool = adbapi.ConnectionPool('psycopg2', user=config['dbuser'], password=config['dbpass'], database=config['dbname'], host=config['dbhost'], port=config['dbport'], cp_reconnect=True, client_encoding='utf-8', connection_factory=NamedTupleConnection, ) st = Storage(dbpool) elif config['backend'] == 'memory': from idavoll.memory_storage import Storage st = Storage() bs = BackendService(st) bs.setName('backend') bs.setServiceParent(s) # Set up XMPP server-side component with publish-subscribe capabilities cs = Component(config["rhost"], int(config["rport"]), config["jid"].full(), config["secret"]) cs.setName('component') cs.setServiceParent(s) cs.factory.maxDelay = 900 if config["verbose"]: cs.logTraffic = True FallbackHandler().setHandlerParent(cs) VersionHandler('Idavoll', __version__).setHandlerParent(cs) DiscoHandler().setHandlerParent(cs) resource = IPubSubResource(bs) resource.hideNodes = config["hide-nodes"] resource.serviceJID = config["jid"] ps = PubSubService(resource) ps.setHandlerParent(cs) resource.pubsubService = ps return s