Am 05.11.2013 um 13:25 schrieb Laufens Van Houtven <>:

You probably want to read this:

There's a number of ways you can use twistd web, for example with a tac file, but personally I always opt for using a Twisted plugin, so you instead do twistd mything :)

I try to write the plugin now:
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 meteoFactory

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
return internet.TCPServer( int(options['port'], 
interface=options['ipv4_address'], ## how do it set the ip6 address?

serviceMaker = MeteoServiceMaker()
--- relevant part of
resource = RootWeatherPage()
meteoFactory = Site(resource)
Currently, this gives following error:
[meteo] [www4:py-venv/meteo/meteo] root# twistd --help
Unhandled Error
Traceback (most recent call last):
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/", line 450, in __str__
    return self.getSynopsis() + '\n' + self.getUsage(width=None)
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/", line 486, in getUsage
    for (cmd, short, parser, desc) in self.subCommands:
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/application/", line 631, in subCommands
    for plug in sorted(plugins, key=attrgetter('tapname')):
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/", line 209, in getPlugins
    allDropins = getCache(package)
--- <exception caught here> ---
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/", line 167, in getCache
    provider = pluginModule.load()
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/", line 383, in load
    return self.pathEntry.pythonPath.moduleLoader(
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/", line 266, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/", line 205, in _importAndCheckStack
    return __import__(importName)
exceptions.SyntaxError: invalid syntax (, line 29)
Line 29 is
serviceMaker = MeteoServiceMaker()
What is wrong there?

PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius