return 404 for non-existant files
authorTero Marttila <terom@fixme.fi>
Wed, 06 Jan 2010 16:41:26 +0200
changeset 37 a6fc2c58e25b
parent 36 caabf287c75e
child 38 0abb7289d4b8
return 404 for non-existant files
pngtile/wsgi.py
--- a/pngtile/wsgi.py	Wed Jan 06 16:32:00 2010 +0200
+++ b/pngtile/wsgi.py	Wed Jan 06 16:41:26 2010 +0200
@@ -102,8 +102,6 @@
     
     # build absolute path
     image_path = os.path.abspath(os.path.join(DATA_ROOT, image_name))
-
-    print image_name, image_path
     
     # ensure the path points inside the data root
     if not image_path.startswith(DATA_ROOT) :
@@ -112,9 +110,12 @@
 
     if os.path.isdir(image_path) :
         return Response(dir_view(req, image_name, image_path), content_type="text/html")
+    
+    elif not os.path.exists(image_path) :
+        raise exceptions.NotFound(image_name)
 
     elif not image_name or not image_name.endswith('.png') :
-        raise exceptions.BadRequest("no .png path given")
+        raise exceptions.BadRequest("Not a PNG file")
     
 
     # get Image object