Hi Nick, Is there a resource page I can view that goes into this in more depth? It was one area I didn't find any examples or documentation for and would rather not re-invent the wheel if this has been standardized with the usual method you outlined.
I was reviewing a few status codes: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html This led me to wonder if in Python we can pull the status code returned for the current page to display during development, and if there was some way to alter the status code on pages served like we would alter MIME: self.response.headers['Content-Type'] = "application/xml" Then I could use the proper status code depending on error page? On Sep 14, 1:01 pm, "Nick Johnson (Google)" <[email protected]> wrote: > Hi Pat, > > Sending a redirect in case of error is generally a bad idea, for several > reasons: > - It disguises the error as a redirect for clients (Eg, 302 instead of 500) > - By redirecting the user to the error page, they can no longer simply hit > refresh to try again for transient errors, nor can they copy the URL that's > problematic. > > Instead, the usual approach is something like this: > > - Define a common base class that subclasses webapp.RequestHandler. > - Override the error(code) method to generate and return an error page. > - Make all your app's handlers inherit from your base handler. > - Call self.error(code) and return whenever you need to. > > -Nick > > > > On Mon, Sep 14, 2009 at 8:28 PM, PatHaugen <[email protected]> wrote: > > > Currently the simplest way I've handled errors is by making a page > > like others: > > > class ErrorPage(webapp.RequestHandler): > > ... > > application = webapp.WSGIApplication( > > ... > > ('/errorpage', ErrorPage), > > > Then, I use: > > self.redirect('/errorpage') > > > In any and all if/else branches where there should be an error and I > > want to stop running the remaining code. > > > However, I was wondering if there was a better way than just using the > > 'self.redirect' to handle errors and perform stops on running code? > > -- > Nick Johnson, Developer Programs Engineer, App Engine --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" 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/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
