Ticket #637: odd-filenaming-637.patch

File odd-filenaming-637.patch, 2.9 KB (added by thijs, 6 years ago)

patch against r24262

  • doc/core/howto/tutorial/intro.xhtml

     
    156156<p>After saving the next example (finger11.py) as <q>finger.tac</q>, 
    157157read on to find out how to run this code using the twistd utility.</p> 
    158158 
    159 <a href="listings/finger/finger11.py" class="py-listing">finger11.py</a> 
    160  
    161  
    162  
    163159<h2>twistd</h2> 
    164160 
    165161<p>This is how to run <q>Twisted Applications</q> &mdash; files which define an 
     
    170166application developer can concentrate on writing his networking code. 
    171167</p> 
    172168 
     169<a href="listings/finger/finger11.tac" class="py-listing">finger11.tac</a> 
     170 
    173171<pre class="shell"> 
    174 root% twistd -ny finger.tac # just like before 
    175 root% twistd -y finger.tac # daemonize, keep pid in twistd.pid 
    176 root% twistd -y finger.tac --pidfile=finger.pid 
    177 root% twistd -y finger.tac --rundir=/ 
    178 root% twistd -y finger.tac --chroot=/var 
    179 root% twistd -y finger.tac -l /var/log/finger.log 
    180 root% twistd -y finger.tac --syslog # just log to syslog 
    181 root% twistd -y finger.tac --syslog --prefix=twistedfinger # use given prefix 
     172root% twistd -ny finger11.tac # just like before 
     173root% twistd -y finger11.tac # daemonize, keep pid in twistd.pid 
     174root% twistd -y finger11.tac --pidfile=finger.pid 
     175root% twistd -y finger11.tac --rundir=/ 
     176root% twistd -y finger11.tac --chroot=/var 
     177root% twistd -y finger11.tac -l /var/log/finger.log 
     178root% twistd -y finger11.tac --syslog # just log to syslog 
     179root% twistd -y finger11.tac --syslog --prefix=twistedfinger # use given prefix 
    182180</pre> 
    183181 
    184182</body> 
  • doc/core/howto/tutorial/listings/finger/finger11.py

     
    1 # Read username, output from non-empty factory, drop connections 
    2 # Use deferreds, to minimize synchronicity assumptions 
    3 # Write application. Save in 'finger.tpy' 
    4 from twisted.application import internet, service 
    5 from twisted.internet import protocol, reactor, defer 
    6 from twisted.protocols import basic 
    7 class FingerProtocol(basic.LineReceiver): 
    8     def lineReceived(self, user): 
    9         self.factory.getUser(user 
    10         ).addErrback(lambda _: "Internal error in server" 
    11         ).addCallback(lambda m: 
    12                       (self.transport.write(m+"\r\n"), 
    13                        self.transport.loseConnection())) 
    14 class FingerFactory(protocol.ServerFactory): 
    15     protocol = FingerProtocol 
    16     def __init__(self, **kwargs): self.users = kwargs 
    17     def getUser(self, user): 
    18         return defer.succeed(self.users.get(user, "No such user")) 
    19  
    20 application = service.Application('finger', uid=1, gid=1) 
    21 factory = FingerFactory(moshez='Happy and well') 
    22 internet.TCPServer(79, factory).setServiceParent( 
    23     service.IServiceCollection(application))