[Twisted-web] Twisted Network Programming Essentials

Stephen Nightingale j_s_nightingale at yahoo.co.uk
Tue Nov 22 03:07:57 MST 2005

  It works better when I use 'class WordCountProxyClient'
  instead of 'class WordCountProxy'.
  Sorry to have troubled you.
  Though I must say, the real problem was easier to find when I ran it on  Linux, than on XP.  Different sets of error messages were given.
  (Also easier to find after Tommy V encouraged me to inspect my code
  more carefully :>)
  Stephen Nightingale.
Tommi Virtanen <tv at twistedmatrix.com> wrote:  On Tue, 2005-11-22 at 00:59 +0000, Stephen Nightingale wrote:
> Fine Book.  I'm working through the examples.
> Hit a problem with the wordcountproxy.py example,
> under the explanation of HTTP Proxy Servers, on page 62..
> As this __might__ be an issue with Twisted itself,
> I'm cross-posting here as well as back to O'Reilly errata.
> The issue is that the:
> 'reactor.listenTCP(WEB_PORT, WebReportFactory(counter))'
> call precipitates an error message in  _getfullpathname in
> Lib/ntpath.py, called from web/http.py, and the error is:
> 'TypeError: coercing to Unicode: need string or buffer, WordCounter
> found'
> I wonder if anyone else has come across this issue?
> Any insights gratefully received,

Did you type it in yourself? It seems like the wordCounter
argument to WebReportFactory.__init__ is getting to
HTTPFactory.__init__, which seems to think it is logPath.
But the book I have in front of me seems to be correct:

class WebReportFactory(http.HTTPFactory):
    def __init__(self, wordCounter):
        self.wordCounter = wordCounter
    counter = WordCounter()
    reactor.listenTCP(WEB_PORT, WebReportFactory(counter))

  Win a Yahoo! Vespa NEW - Yahoo! Cars has 3 Vespa LX125s to be won Enter Now! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20051122/6d42a356/attachment.htm

More information about the Twisted-web mailing list