durusmail: quixote-users: allowing an empty body
allowing an empty body
2003-09-03
2003-09-03
2003-09-03
2003-09-03
2003-09-03
allowing an empty body
John Belmonte
2003-09-03
Hello,

I am designing a web application using Quixote and the REST architecture
style.  Sometimes I'd like to generate a response that has no body, for
example:

     HTTP/1.1 201 Created
     Location: http://example.net/some-resource/555

However, the Quixote framework does not allow HTTP request handlers to
return None.  From Publisher.try_publish():

     if output is None:
         raise RuntimeError, 'callable %s returned None' % repr(object)

In light of the fact that it's reasonable to return no body, what is the
purpose of this exception?  Is it necessary?  The Quixote code already
seems to handle output being None (the code always tests before
referencing it).

I know that I can have my handler return an empty string, but this will
cause the Content-type and Content-length headers to be set due to the
way HTTPResponse works.  I'd really just like to return None when I mean
no body.

-John Belmonte


--
http:// if   l .o  /


reply