[Twisted-web] mailman with twisted

Andrea Arcangeli andrea at cpushare.com
Wed Feb 9 22:47:51 MST 2005


I'm trying to setup mailman, but I had not much luck so far.

I'm testing it like this:

import pwd
uid = pwd.getpwnam('andrea')[2]
gid = int(file('/etc/mailman/mailman.cgi-gid').read())

from twisted.application import service
application = service.Application('mailman', uid=uid, gid=gid)

from twisted.application import internet, service

s = service.MultiService()

from twisted.web import server, distrib, twcgi, static
from twisted.spread import pb

r = twcgi.CGIDirectory('/usr/lib/mailman/cgi-bin')
r.putChild('pipermail', static.File('/var/lib/mailman/archives/public'))

site = server.Site(r)

internet.UNIXServer('/var/lib/mailman/.twistd-web-pb',
		    pb.PBServerFactory(distrib.ResourcePublisher(site))).setServiceParent(s)

s.setServiceParent(service.IServiceCollection(application))


However the above isn't good, the socket is created word writeable, and
it's owned by root, the setuid is executed later on (which is a good
thing normally to bind ports <1024, but not in this case). And if the file is
already present I get the below problem. Why can't simply bind the device
without recreating it? I don't recall any bind(2) limitation in the kernel that
forces to recreate the device. At least there should be an option to auto-delete it.

opteron:/home/andrea/cpushare/server/cpushare/cpushare/web # twistd -r poll -noy mailman.tac
2005/02/10 06:45 CET [-] Log opened.
2005/02/10 06:45 CET [-] twistd SVN-trunk (/home/andrea/bin/i686/python-20050207/bin/python 2.4.1) starting up
2005/02/10 06:45 CET [-] reactor class: twisted.internet.pollreactor.PollReactor
2005/02/10 06:45 CET [-] Loading mailman.tac...
2005/02/10 06:45 CET [-] /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/web/woven/interfaces.py:60: twisted.python.components.ComponentsDeprecationWarning: Please don't use __adapt__ on Interface subclasses
2005/02/10 06:45 CET [-] /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/web/woven/interfaces.py:135: twisted.python.components.ComponentsDeprecationWarning: Please don't use __adapt__ on Interface subclasses
2005/02/10 06:45 CET [-] Loaded.
2005/02/10 06:45 CET [-] twisted.spread.pb.PBServerFactory starting on "'/var/lib/mailman/.twistd-web-pb'"
2005/02/10 06:45 CET [-] Starting factory <twisted.spread.pb.PBServerFactory instance at 0x55e36bcc>
2005/02/10 06:45 CET [-] Traceback (most recent call last):
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python/bin/twistd", line 25, in ?
2005/02/10 06:45 CET [-]     run()
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/scripts/twistd.py", line 171, in run
2005/02/10 06:45 CET [-]     app.run(runApp, ServerOptions)
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/application/app.py", line 221, in run
2005/02/10 06:45 CET [-]     runApp(config)
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/scripts/twistd.py", line 162, in runApp
2005/02/10 06:45 CET [-]     startApplication(config, application)
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/scripts/twistd.py", line 146, in startApplication
2005/02/10 06:45 CET [-]     service.IService(application).privilegedStartService()
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/application/service.py", line 194, in privilegedStartService
2005/02/10 06:45 CET [-]     service.privilegedStartService()
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/application/service.py", line 194, in privilegedStartService
2005/02/10 06:45 CET [-]     service.privilegedStartService()
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/application/internet.py", line 65, in privilegedStartService
2005/02/10 06:45 CET [-]     self._port = self._getPort()
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/application/internet.py", line 82, in _getPort
2005/02/10 06:45 CET [-]     return getattr(reactor, 'listen'+self.method)(*self.args, **self.kwargs)
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/internet/posixbase.py", line 322, in listenUNIX
2005/02/10 06:45 CET [-]     p.startListening()
2005/02/10 06:45 CET [-]   File "/home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/internet/unix.py", line 85, in startListening
2005/02/10 06:45 CET [-]     raise CannotListenError, (None, self.port, le)
2005/02/10 06:45 CET [-] twisted.internet.error.CannotListenError: Couldn't listen on any:/var/lib/mailman/.twistd-web-pb: (98, 'Address already in use').

Second worse problem is in pb, when I connect the nevow server to this
remote server with this:

class something(rend.Page):
[..]
	from twisted.web import server, distrib, twcgi, static
	child_mailman = distrib.ResourceSubscription('unix', '/var/lib/mailman/.twistd-web-pb')
[..]

When I try to fetch /mailman I get this:

2005/02/10 05:52 CET [Broker,client] [Failure instance: Traceback: twisted.spread.jelly.InsecureJelly, Class not allowed for instance: twisted.internet.defer.Deferred <Deferred at 0x561eed6c>
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/pb.py:855:_sendMessage
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/pb.py:809:serialize
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/jelly.py:838:jelly
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/jelly.py:444:jelly
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/jelly.py:400:jelly
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/flavors.py:304:jellyFor
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/jelly.py:448:jelly
        /home/andrea/bin/i686/python-20050207/lib/python2.4/site-packages/twisted/spread/jelly.py:473:jelly
        ]
2005/02/10 06:08 CET [Broker,client] could not connect to distributed web service: connection dropped
2005/02/10 06:08 CET [Broker,client] Stopping factory <twisted.spread.pb.PBClientFactory instance at 0x561ffa6c>

The only document I found about it, is this:

http://twistedmatrix.com/pipermail/twisted-web/2004-July/000555.html

The absurd thing is that the test programs works fine (test_distrib.py and
silly-web.py both works).

I'm lost... ;) (last resort is always to run apache on port 8080 just
for mailman, but I'd rather avoid opening two webservers in the
firewall)

This problem must be already solved somehow since twistedmatrix.com has
it working.

I'm running SVN trunk for everything, except python that is the 2.4
branch.

Thanks in advance for any help.



More information about the Twisted-web mailing list