I m试图从Tundo网吧获得“世界”的榜样。 I m 预示着新 tornado, 并完全是新到的。 我已具体指明了以下手稿,即:
class EchoWebSocket(tornado.websocket.WebSocketHandler):
def open(self):
print "WebSocket opened"
def on_message(self, message):
self.write_message(u"You said: " + message)
def on_close(self):
print "WebSocket closed"
and call it from javascript using
var ws = new WebSocket("ws://localhost:6665/websocket");
ws.onopen = function() {
ws.send("Hello, world");
};
ws.onmessage = function (evt) {
alert(evt.data);
};
也可从笔记中取。 我立即举出三个例外:
[E 111123 17:45:54 iostream:233] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
[E 111123 17:45:54 iostream:221] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 199, in _handle_events
self._handle_read()
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 258, in _handle_read
if self._read_from_buffer():
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 325, in _read_from_buffer
self._consume(loc + delimiter_len))
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
[E 111123 17:45:54 ioloop:281] Exception in I/O handler for fd 4
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/ioloop.py", line 269, in start
self._handlers[fd](fd, events)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 199, in _handle_events
self._handle_read()
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 258, in _handle_read
if self._read_from_buffer():
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 325, in _read_from_buffer
self._consume(loc + delimiter_len))
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
which I confess to being unable to properly parse, and I m nervous to dip into tornado.web. Is there something obvious I m doing wrong? I m using tornado 1.2.1.