AuthenticatedFileHandler uses ContentsManager to serve files and notebooks

In reference to #6613 I'm adding this PR. Rather than working on paths, it will use the current ContentsManager to get the contents of a file.

I tested this with the default `FileContentsManager` and our own `MongoContentsManager`.

There might be a better way to serve the file instead of `write()` and `flush()`.

Let me know what you think
Totally agree and considered that before.

Where can I put my own FilesHandler? How to switch it later?

 

-----Original Message-----
From: Min RK <notifications@github.com>
To: ipython/ipython <ipython@noreply.github.com>
Cc: Manuel Riel <m@nuelriel.com>
Sent: Sat, 04 Oct 2014 21:31
Subject: Re: [ipython] AuthenticatedFileHandler uses ContentsManager to serve files and notebooks (#6620)

> @@ -284,13 +284,22 @@ class AuthenticatedFileHandler(IPythonHandler, web.StaticFileHandler):
>  
>      @web.authenticated
>      def get(self, path):
> -        if os.path.splitext(path)[1] == '.ipynb':
> -            name = os.path.basename(path)
> -            self.set_header('Content-Type', 'application/json')
> +            if path.find('/') > -1:

AuthenticatedFileHandler shouldn't be modified to to use contents manager. A new `FilesHandler` should be added that serves files from the contents manager. It shouldn't inherit from StaticFileHandler. It also needs to be careful to set content-type headers, etc. 

---
Reply to this email directly or view it on GitHub:
https://github.com/ipython/ipython/pull/6620/files#r18431156