On 05/06/2006, at 17:17, Helio Pereira wrote:
> Is there a way for me to send errors (with my description) inside a
> controller?

Yep,

> return (400, "Bad Request", {'Content-Type': 'text/plain'}, 'You sent
> me garbage')

raise cherrypy.HTTPError(400, "You sent me garbage")

Cherrypy seems to override the Content-type header if you provide it  
(see below) when raising HTTPError exceptions, I'm unaware of any way  
around this but I'm sure it's possible (maybe ask in the CP list?).


> return (200, "OK", {'Content-Type': 'text/plain', 'Pragma':'no- 
> cache'},
> 'Test message... OK!!!')

Extra response headers can be added to cherrypy.response.headers  
inside your controller method, ie:

@expose(content_type='text/plain')
def method(self):
        cherrypy.response.headers['Pragma'] = 'no-cache'
        return 'Test message... OK!!!'

HTH,
Alberto


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to