Opened 7 years ago

Last modified 7 years ago

#6771 defect new

Outdated tutorial?

Reported by: Jerzy Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

In your tutorial: http://twistedmatrix.com/documents/current/core/howto/servers.html

In "Using protocol" you have "return QOTD()" but it should be "return QOTD(self)". In another place you have self.factory.numProtocols, but as i checked there's no numProtocols variable in factory class. I'm sure there's might be more of this...

Change History (2)

comment:1 Changed 7 years ago by habnabit

class QOTD(Protocol):

    def connectionMade(self):
        self.transport.write("An apple a day keeps the doctor away\r\n") 
        self.transport.loseConnection()

This is the definition of the QOTD Protocol. It doesn't define an __init__, so you must call it as QOTD().

It does look like self.factory.numProtocols needs an initial assignment, though.

comment:2 Changed 7 years ago by Jean-Paul Calderone

This is the definition of the QOTD Protocol. It doesn't define an init, so you must call it as QOTD().

There is an Echo protocol which defines __init__ as requiring the factory as an argument. The reporter probably mixed up QOTD and Echo. The Echo protocol isn't used elsewhere in the howto so it's a little bit easy to see how this could be confusing.

It does look like self.factory.numProtocols needs an initial assignment, though.

Quite so. But... the factory used with Echo isn't defined anywhere in the howto. So where would that assignment be added? Can there really be a bug in code that isn't even part of the document? :)

Note: See TracTickets for help on using tickets.