In other words, the question would be "how do I intercept 400+ errors
before the reponse is sent to the browser".

Diggin' web2py's code (main.py, line 226) I found an possible way to
do it:

# ##################################################
# access the requested application
# ##################################################

if not os.path.exists(request.folder):
    if request.application=='init':
        request.application = 'welcome'
        redirect(html.URL(r=request))

    #
    # No url match so, if set in config (routes.py?),
    # call special controller/method handler here (error/error).
    #
    # [call method here]
    #
    # If not set, go on with standard error http error:
    #

    raise HTTP(400, error_message,
               web2py_error='invalid application')


I lack in-depth knowledge of web2py's internals but I'll try to
implement this and send a patch.



-

On 26 mai, 21:57, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Not sure I completely understand the issue but as long as it is ok
> with you fine.
>
> On May 26, 2:32 pm, desfrenes <desfre...@gmail.com> wrote:
>
> > Thanks.
>
> > I first played with routes_onerror but it was useless for me since it
> > affects only redirection (I needed to trap the error *before*
> > redirection occurs).
>
> > Then I found this 
> > thread:http://groups.google.com/group/web2py/browse_thread/thread/95910208a4...
>
> > Using a regexp to map .html urls to a controller is ok and I will
> > probably use that, but it means the url still has to have ".html" in
> > it, thus not reaching the goal of having a complete arbitrary url. But
> > it's ok though.
>
> > On 26 mai, 08:17, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > There may be an easier to implement Djangoflatpagesin web2py but if
> > > you need to trap error codes, look into
>
> > > web2py/routes.examples.py
>
> > > Massimo
>
> > > On May 26, 12:51 am, desfrenes <desfre...@gmail.com> wrote:
>
> > > > Hello,
>
> > > > I'm trying to build something similar to the flatpage application in
> > > > django, that is an app that maps a simple content to an arbitrary url.
> > > > To do so I have to trap 400 and 404 errors and then see if a content
> > > > is attached to this url. If so, display it, if not, raise the error
> > > > again.
>
> > > > How can I trap 400 and 404 errors ?
>
> > > > Cheers
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to