summaryrefslogtreecommitdiff
path: root/paste/fileapp.py
diff options
context:
space:
mode:
authormaluke <devnull@localhost>2008-05-30 19:46:19 +0000
committermaluke <devnull@localhost>2008-05-30 19:46:19 +0000
commit354d6922774bf16f8a00a30921af23ec75fc851c (patch)
tree33451b4521e6403e01dfbfdb4d7daffdc1be8e23 /paste/fileapp.py
parentee790b8d10e775dc345bf19be1e90fc7a656857d (diff)
downloadpaste-354d6922774bf16f8a00a30921af23ec75fc851c.tar.gz
added DirectoryApp.make_fileapp to allow some customization
Diffstat (limited to 'paste/fileapp.py')
-rw-r--r--paste/fileapp.py5
1 files changed, 4 insertions, 1 deletions
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)