There's a little bug that keeps this from working: raise webob.exc.HTTPNotFound('blah blah', content_type='application/xml')
(fixed on trunk though) But you should be able to do this: e = webob.exc.HTTPNotFound() e.body = '<blah />' e.content_type = 'application/xml' raise e # or e.exception on python2.4 Now... if "html" and "*/*" aren't in the HTTP Accept header, the automatic body *should* be plain text, not HTML (but it won't be XML, if that's what you want). It's also possible that Pylons' status code redirect thing is rewriting the error response; so if this doesn't work then the problem is probably there. On Tue, Sep 29, 2009 at 8:14 AM, Chris <crso...@googlemail.com> wrote: > > Hi > > We are creating a web service using Pyons that uses XML as the primary > response content type. We have had some trouble when using abort() > because it raises a webob.exc.WSGIHTTPException which has a HTML > response as it's default body. > > The workaround we have implemented overrides _inspect_call() in > base.py like this > > def _inspect_call(self, func): > result = super(BaseController, self)._inspect_call(func) > if hasattr(result,'empty_body'): > result.empty_body = True > > return result > > > Perhaps it should be the default to always set empty_body to True when > a WSGIHTTPException is raised or when it is caught. > > > > -- Ian Bicking | http://blog.ianbicking.org | http://topplabs.org/civichacker --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en -~----------~----~----~----~------~----~------~--~---