From 354d6922774bf16f8a00a30921af23ec75fc851c Mon Sep 17 00:00:00 2001 From: maluke Date: Fri, 30 May 2008 19:46:19 +0000 Subject: added DirectoryApp.make_fileapp to allow some customization --- paste/fileapp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'paste/fileapp.py') diff --git a/paste/fileapp.py b/paste/fileapp.py index 16bc0ed..81d4786 100644 --- a/paste/fileapp.py +++ b/paste/fileapp.py @@ -265,6 +265,7 @@ class DirectoryApp(object): """ Returns an application that dispatches requests to corresponding FileApps based on PATH_INFO. FileApp instances are cached. This app makes sure not to serve any files that are not in a subdirectory. + To customize FileApp creation override ``DirectoryApp.make_fileapp`` """ def __init__(self, path): @@ -274,6 +275,8 @@ class DirectoryApp(object): assert os.path.isdir(self.path) self.cached_apps = {} + make_fileapp = FileApp + def __call__(self, environ, start_response): path_info = environ['PATH_INFO'] app = self.cached_apps.get(path_info) @@ -282,7 +285,7 @@ class DirectoryApp(object): if not os.path.normpath(path).startswith(self.path): app = HTTPForbidden() elif os.path.isfile(path): - app = FileApp(path) + app = self.make_fileapp(path) self.cached_apps[path_info] = app else: app = HTTPNotFound(comment=path) -- cgit v1.2.1