IPython Documentation

Table Of Contents

Previous topic

Module: html.auth.logout

Next topic

Module: html.base.zmqhandlers

This Page

Module: html.base.handlers

Base Tornado handlers for the notebook.

Authors:

  • Brian Granger

6 Classes

class IPython.html.base.handlers.AuthenticatedHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

A RequestHandler with an authenticated user.

logged_in

Is a user currently logged in?

login_available

May a user proceed to log in?

This returns True if login capability is available, irrespective of whether the user is already logged in or not.

password

our password

class IPython.html.base.handlers.IPythonHandler(application, request, **kwargs)

Bases: IPython.html.base.handlers.AuthenticatedHandler

IPython-specific extensions to authenticated handling

Mostly property shortcuts to IPython-specific settings.

get_error_html(status_code, **kwargs)

render custom error pages

get_json_body()

Return the body of the request as JSON data.

get_template(name)

Return the jinja template object for a given name

log

use the IPython log by default, falling back on tornado’s logger

class IPython.html.base.handlers.Template404(application, request, **kwargs)

Bases: IPython.html.base.handlers.IPythonHandler

Render our 404 template

class IPython.html.base.handlers.AuthenticatedFileHandler(application, request, **kwargs)

Bases: IPython.html.base.handlers.IPythonHandler, tornado.web.StaticFileHandler

static files should only be accessible when logged in

validate_absolute_path(root, absolute_path)

Validate and return the absolute path.

Requires tornado 3.1

Adding to tornado’s own handling, forbids the serving of hidden files.

class IPython.html.base.handlers.FileFindHandler(application, request, **kwargs)

Bases: tornado.web.StaticFileHandler

subclass of StaticFileHandler for serving files from a search path

classmethod get_absolute_path(roots, path)

locate a file to serve on our static file search path

validate_absolute_path(root, absolute_path)

check if the file should be served (raises 404, 403, etc.)

class IPython.html.base.handlers.TrailingSlashHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

Simple redirect handler that strips trailing slashes

This should be the first, highest priority handler.

1 Function

IPython.html.base.handlers.json_errors(method)

Decorate methods with this to return GitHub style JSON errors.

This should be used on any JSON API on any handler method that can raise HTTPErrors.

This will grab the latest HTTPError exception using sys.exc_info and then:

  1. Set the HTTP status code based on the HTTPError
  2. Create and return a JSON body with a message field describing the error in a human readable form.