~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/tutorial/listings/finger/finger07.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Read username, output from non-empty factory, drop connections
 
2
 
 
3
from twisted.internet import protocol, reactor
 
4
from twisted.protocols import basic
 
5
 
 
6
class FingerProtocol(basic.LineReceiver):
 
7
    def lineReceived(self, user):
 
8
        self.transport.write(self.factory.getUser(user)+"\r\n")
 
9
        self.transport.loseConnection()
 
10
 
 
11
class FingerFactory(protocol.ServerFactory):
 
12
    protocol = FingerProtocol
 
13
 
 
14
    def __init__(self, **kwargs):
 
15
        self.users = kwargs
 
16
 
 
17
    def getUser(self, user):
 
18
        return self.users.get(user, "No such user")
 
19
 
 
20
reactor.listenTCP(1079, FingerFactory(moshez='Happy and well'))
 
21
reactor.run()