##// END OF EJS Templates
Compatibility fix for Tornado 3.x
Thomas Kluyver -
Show More
@@ -1,28 +1,43
1 1 """Tornado handlers for the terminal emulator."""
2 2
3 3 # Copyright (c) IPython Development Team.
4 4 # Distributed under the terms of the Modified BSD License.
5 5
6 import tornado
6 7 from tornado import web
7 8 import terminado
8 9 from ..base.handlers import IPythonHandler
9 10
10 11 class TerminalHandler(IPythonHandler):
11 12 """Render the terminal interface."""
12 13 @web.authenticated
13 14 def get(self, term_name):
14 15 self.write(self.render_template('terminal.html',
15 16 ws_path="terminals/websocket/%s" % term_name))
16 17
17 18 class NewTerminalHandler(IPythonHandler):
18 19 """Redirect to a new terminal."""
19 20 @web.authenticated
20 21 def get(self):
21 22 name, _ = self.application.terminal_manager.new_named_terminal()
22 23 self.redirect(name, permanent=False)
23 24
24 25 class TermSocket(terminado.TermSocket, IPythonHandler):
25 26 def get(self, *args, **kwargs):
26 27 if not self.get_current_user():
27 28 raise web.HTTPError(403)
29
30 # FIXME: only do super get on tornado ≥ 4
31 # tornado 3 has no get, will raise 405
32 if tornado.version_info >= (4,):
28 33 return super(TermSocket, self).get(*args, **kwargs)
34
35 def open(self, *args, **kwargs):
36 if tornado.version_info < (4,):
37 try:
38 self.get(*self.open_args, **self.open_kwargs)
39 except web.HTTPError:
40 self.close()
41 raise
42
43 super(TermSocket, self).open(*args, **kwargs)
General Comments 0
You need to be logged in to leave comments. Login now