Re: Status codes for user errors

2007-11-02 Thread Alberto Valverde

Mike Orr wrote:
 Sometimes my controllers discover a user error: a URL pointing to a
 nonexistent database record, or query/form input that doesn't match
 what the form HTML would have allowed.  The Pylons error system isn't
 quite what I want; I'd rather send back a regular page with the site
 decorations and a message saying That record doesn't exist, try
 searching or You don't seem like a real human. -- with a 400-series
 status.  Because just aborting with 500 makes it look like the site is
 buggy, and a text error message doesn't have the links to get them
 back on track.  I could adjust the error template style but it seems
 like overkill when I can just do it in the controller.  Is there any
 problem with just changing the status in the controller and returning
 an alternate template page?
 

There shouldn't be, just do:

response.status_code = 500

Inside the controller method so the correct headers are set (I haven't
found a way to alter the message though, you might have to drop to bare
WSGI to do that) and then render the template you see fit.

Alberto

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---



Status codes for user errors

2007-11-01 Thread Mike Orr

Sometimes my controllers discover a user error: a URL pointing to a
nonexistent database record, or query/form input that doesn't match
what the form HTML would have allowed.  The Pylons error system isn't
quite what I want; I'd rather send back a regular page with the site
decorations and a message saying That record doesn't exist, try
searching or You don't seem like a real human. -- with a 400-series
status.  Because just aborting with 500 makes it look like the site is
buggy, and a text error message doesn't have the links to get them
back on track.  I could adjust the error template style but it seems
like overkill when I can just do it in the controller.  Is there any
problem with just changing the status in the controller and returning
an alternate template page?

-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---