I made some investigation and here is results.

1) "routes_onerror" do not work with static files. It is cased by
lines 488 and 489 in gluon.main

                if static_file:
                    return http_response.to(responder)

I comment them and static files HTTP errors works now.

2) I am using routes_app (domain for every application) so
routes_onerror can't be in global routest.py (in web2py root) but it
must be in application routest.py

Hope it helps somebody

Bye!

On Sep 9, 2:38 am, kachna <petr.marti...@gmail.com> wrote:
> Hi,
> I am trying to catch "invalid request" after requesting non-existing
> file from static folder of application "eshop". My routest.py:
>
> routes_onerror = [
>         #('eshop/400', '/eshop/default/HTTP_404'),
>         ('*/*', '/eshop/default/HTTP_error')
> ]
>
> routes_app = (
>         (r'.*http://meganabytek\.cz.*', r'eshop'),
>         (r'.*http://www\.meganabytek\.cz.*', r'eshop'),
>
>         (r'.*http://kitenavigator\.com.*', r'kitenavigator'),
>         (r'.*http://www\.kitenavigator\.com.*', r'kitenavigator'),
>
>         (r'.*http://blog\.meganabytek\.cz.*', r'blog'),
>         (r'.*http://vysocinacup\.meganabytek\.cz.*', r'o_apmas'),
>
>         #('/eshop/appadmin/$f', '/eshop/appadmin/$f'), # enable
> administration
>         #('/eshop/static/$f', '/eshop/static/$f'), # enable static files
>
> )
>
> On my PC it works good. Just request.vars.requested_uri in HTTP_error
> function is None. It stop working When I move the code on hosting.
> Looks like on http error happend but in uwsgi log I can see:
>
> GET /eshop/static/photo.thumb.9ee2c7f07e9b810b.
> 4b30315f736b72696e6b612d757a617672656e612d6b6f6d622d2e6a7067.jpg =>
> generated 573 bytes in 2 msecs (HTTP/1.1 404) 3 headers in 115 bytes
> (1 switches on core 0)
>
> Can anybody help me?

Reply via email to