On Thu, Jun 17, 2010 at 2:51 PM, Petr Kobalíček
<[email protected]> wrote:
> Hi devs,
>
> is there somewhere usage guide for FileApp. I used it in past and I'm
> now getting one minor issue, if I want to serve file that not exists,
> I get 500 (Internal Server Error) instead of 404 (Not Found).
>
> My shortened code:
>
> class SomeClass(CoreController):
>
>  ...
>
>  def _serveFile(self, path):
>    fapp = FileApp(path)
>    return fapp(request.environ, self.start_response)
>
> If I want to serve file that not exists, I get 500, following
> exception is raised:
>
>  WindowsError: (in czech locale, means File Not Found)
>
> The line in fileapp (from paste)
>
>        stat = os.stat(self.filename)
>
> The stat can raise exception, it's uncatched in Paste::FileApp
>
> The question is, should I catch all exceptions when serving files or
> this is Paste domain?
>

FileApp assume that the file exist. If you want to handle 404 you can
use StaticURLParser to serve the parent directory instead

--
Gael

> Thank you!
>
> --
> Best regards
> - Petr Kobalicek <http://kobalicek.com>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/pylons-discuss?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to