Twisted Network Programming Essentials
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' The full traceback is given below. N.B. I'm using Python 2.4.1 on Win XP. I wonder if anyone else has come across this issue? Any insights gratefully received, Regards, Stephen Nightingale. 2005/11/21 23:20 GMT Standard Time [-] Log opened. 2005/11/21 23:20 GMT Standard Time [-] __main__.WordCountProxyFactory starting on 8001 2005/11/21 23:20 GMT Standard Time [-] Starting factory <__main__.WordCountProxyFactory instance at 0x00F03878> 2005/11/21 23:20 GMT Standard Time [-] Traceback (most recent call last): 2005/11/21 23:20 GMT Standard Time [-] File "wordcountproxy.py", line 137, in ? 2005/11/21 23:20 GMT Standard Time [-] reactor.listenTCP(WEB_PORT, WebReportFactory(counter)) 2005/11/21 23:20 GMT Standard Time [-] File "D:\Python\Lib\site-packages\twisted\web\http.py", line 1086, in __init__ 2005/11/21 23:20 GMT Standard Time [-] logPath = os.path.abspath(logPath) 2005/11/21 23:20 GMT Standard Time [-] File "d:\Python\lib\ntpath.py", line 500, in abspath 2005/11/21 23:20 GMT Standard Time [-] path = _getfullpathname(path) 2005/11/21 23:20 GMT Standard Time [-] TypeError: coercing to Unicode: need string or buffer, WordCounter found --------------------------------- To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
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 http.HTTPFactory.__init__(self) ... counter = WordCounter() ... reactor.listenTCP(WEB_PORT, WebReportFactory(counter))
Hi,
Thanks for the quick reply.
Yes, I typed it in, after searching for an online verson and not
finding it. My version is attached.. I checked and double-checked
line by line, and believe it is faithful to the original in the book.
Do you know an on-web source where I can find it?
Regards,
Stephen Nightingale.
Tommi Virtanen
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 http.HTTPFactory.__init__(self) ... counter = WordCounter() ... reactor.listenTCP(WEB_PORT, WebReportFactory(counter)) --------------------------------- To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
Ahh,
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
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 http.HTTPFactory.__init__(self) ... counter = WordCounter() ... reactor.listenTCP(WEB_PORT, WebReportFactory(counter)) --------------------------------- Win a Yahoo! Vespa NEW - Yahoo! Cars has 3 Vespa LX125s to be won Enter Now!
participants (2)
-
Stephen Nightingale
-
Tommi Virtanen