handle single static path in FileFindHandler

This commit is contained in:
MinRK 2012-07-20 12:14:09 -05:00
parent 2891a0a8ca
commit 3c6c38289a
2 changed files with 8 additions and 4 deletions

View File

@ -749,6 +749,8 @@ class FileFindHandler(web.StaticFileHandler):
_static_paths = {}
def initialize(self, path, default_filename=None):
if isinstance(path, basestring):
path = [path]
self.roots = tuple(
os.path.abspath(os.path.expanduser(p)) + os.path.sep for p in path
)
@ -849,14 +851,16 @@ class FileFindHandler(web.StaticFileHandler):
could be determined.
"""
# begin subclass override:
static_path = settings['static_path']
static_paths = settings['static_path']
if isinstance(static_paths, basestring):
static_paths = [static_paths]
roots = tuple(
os.path.abspath(os.path.expanduser(p)) + os.path.sep for p in static_path
os.path.abspath(os.path.expanduser(p)) + os.path.sep for p in static_paths
)
try:
abs_path = filefind(path, roots)
except Exception:
except IOError:
logging.error("Could not find static file %r", path)
return None

View File

@ -155,7 +155,7 @@ class NotebookWebApplication(web.Application):
settings = dict(
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
static_path=ipython_app.static_file_path,
static_handler_class = FileFindHandler,
cookie_secret=os.urandom(1024),
login_url="%s/login"%(base_project_url.rstrip('/')),