from twisted.application import internet from pubsubin.web import routes from pubsubin.control import Router, PublisherType from nevow import appserver class WebPublisher(PublisherType): def __init__(self, router, application): PublisherType.__init__(self, 'web', router, application) def start(self): site = appserver.NevowSite(routes.WebRoot(self.router)) webServer = internet.TCPServer(Router.getConfig('webport'), site) webServer.setServiceParent(self.application) Router.addPublisher(WebPublisher)
from twisted.application import internet # the following try/except/if has been taken per recommendation from # http://twistedmatrix.com/trac/browser/tags/releases/twisted-10.0.0//twisted/internet/ssl.py try: from twisted.internet import ssl except ImportError: ssl = None if ssl and not ssl.supported: ssl = None from pubsubin.web import routes from pubsubin.control import Router, PublisherType from nevow import appserver class WebSSLPublisher(PublisherType): def __init__(self, router, application): PublisherType.__init__(self, 'webssl', router, application) def start(self): site = appserver.NevowSite(routes.WebRoot(self.router)) sslContext = ssl.DefaultOpenSSLContextFactory(Router.getConfig('sslkey'), Router.getConfig('sslcrt')) webServerSSL = internet.SSLServer(Router.getConfig('webportssl'), site, sslContext) webServerSSL.setServiceParent(self.application) Router.addPublisher(WebSSLPublisher)
return emailToUsername(self.dbpool, msg['from'].lower()).addCallback(doSend) """ def connectionLost(self): self.lines = None class SMTPFactory(smtp.SMTPFactory): def __init__(self, router): smtp.SMTPFactory.__init__(self) self.delivery = MessageDelivery(router) def buildProtocol(self, addr): p = smtp.SMTPFactory.buildProtocol(self, addr) p.delivery = self.delivery return p class EMailPublisher(PublisherType): def __init__(self, router, application): PublisherType.__init__(self, 'email', router, application) def start(self): smtpserver = internet.TCPServer(Router.getConfig('smtpport'), SMTPFactory(self.router)) smtpserver.setServiceParent(self.application) Router.addPublisher(EMailPublisher)