view idavoll/tap.py @ 159:6fe78048baf9

Rework error handling, depend on Twisted Words 0.4.0. Twisted Words 0.4.0 introduced support for stanza error handling, much better than the custom error handling in Idavoll. Also, all protocol-level errors were examined and brought up to date with version 1.8 of JEP-0060. As a result of the error examination, the retrieval of default configuration options using <default/> is now supported properly.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 06 Sep 2006 12:38:47 +0000
parents 6250905b72f6
children 1701c0e2c707
line wrap: on
line source

# Copyright (c) 2003-2006 Ralph Meijer
# See LICENSE for details.

from twisted.application import internet, service
from twisted.internet import interfaces
from twisted.python import usage
import idavoll

class Options(usage.Options):
    optParameters = [
        ('jid', None, 'pubsub'),
        ('secret', None, 'secret'),
        ('rhost', None, '127.0.0.1'),
        ('rport', None, '5347'),
        ('backend', None, 'memory'),
        ('dbuser', None, ''),
        ('dbname', None, 'pubsub'),
    ]

    optFlags = [
        ('verbose', 'v', 'Show traffic'),
        ('hide-nodes', None, 'Hide all nodes for disco')
    ]
    
    def postOptions(self):
        if self['backend'] not in ['pgsql', 'memory']:
            raise usage.UsageError, "Unknown backend!"

def makeService(config):
    return idavoll.makeService(config)