Am 08.11.2013 um 19:43 schrieb Axel Rau <[email protected]>: > > makeService expects a protocol factory, but I have only > meteoFactory = Site(resource) > How do I interface the former to the http protocol? >
After fixing my low-level Python errors (sorry for wasting you time), the attached plugin works out of the box with my original code: --- resource = RootWeatherPage() meteo_factory = Site(resource) ---
from zope.interface import implements from twisted.application.service import IServiceMaker from twisted.application import internet from twisted.plugin import IPlugin from twisted.python import usage from meteo import meteo_factory class Options(usage.Options): optParameters = [ ['port', 'p', 80, 'The port number to listen on.'], ['ipv4_address', '4', None, 'The IPv4 address to listen on.'], ['ipv6_address', '6', None, 'The IPv6 address to listen on.']] class MeteoServiceMaker(object): implements(IServiceMaker, IPlugin) tapname = 'meteo' description = 'A web application for the meteo package' options = Options def makeService(self, options): """ Constructs a TCP server from a factory defined in meteo.py """ return internet.TCPServer( int(options['port']), meteo_factory, interface=options['ipv4_address']) serviceMaker = MeteoServiceMaker()
Next, I have to find a way to define a 2nd interface (IPv6) for TCPServer. Axel --- PGP-Key:29E99DD6 ☀ +49 151 2300 9283 ☀ computing @ chaos claudius
_______________________________________________ Twisted-web mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
