[Twisted-Python] twisted daemonize problem

Marco Giusti marco.giusti at gmail.com
Tue Nov 9 07:53:26 EST 2010

On Tue, Nov 09, 2010 at 06:58:05AM -0500, Neal Becker wrote:
> Thanks for the suggestions.
> I'd also like to add authentication, but it seems rather daunting.

You should not. Add basic or digest authentication is really easy. Take
a look at Calderone's Twisted Web in 60 seconds: HTTP authentication[1],
I read the series time ago and I don't remember exactly the content but
the serie is really well written, the best 60 seconds (per episode)
spent to learn the bases of twisted web.

> Maybe I could just restrict the xmlrpc to listen only on connection from the 
> local host?

yes, you could and twisted tap plugin system helps you on this. Just
create a tap plugin with the options you need. An simple example:

	from twisted.python import usage
	from twisted.plugin import IPlugin
    from twisted.application import strports, service

	class Options(usage.Options):

		optParameters = [
				['port', 'p', '80', 'Listen port.', int],
				['interface', 'i', None, 'Interface to which to bind.'],

	class ProcessXMLRPCServiceMaker(object):
		implements(service.IServiceMaker, IPlugin)
		tapname = "processxmlrpc"
		description = "Remote process control in xmlrpc"
		options = Options

		def makeService(self, options):
			factory = ... # XXX
			description = 'tcp:' + str(config['port'])
			if config['interface']:
				description += ':interface=' + config['interface']
			return strports.service(description, factory)

You can setup the server to listen to localhost and prepare a reverse
proxy that require authentication and that accept connections from all
interfaces, as example.


Dalle virtù che si esigono in un domestico, l'Eccellenza Vostra conosce molti
padroni degni d'esser servitori?
		-- Pierre Augustin Caron de Beaumarchais

More information about the Twisted-Python mailing list