On May 17, 2011, at 12:02 PM, Tres Seaver wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 05/17/2011 10:14 AM, Satchidanand Haridas wrote:
>
>> ---
>> zope.server/branches/achapman-exc-info/src/zope/server/http/wsgihttpserver.py
>> 2011-05-17 12:41:54 UTC (rev 121686)
>> +++
>> zope.server/branches/achapman-exc-info/src/zope/server/http/wsgihttpserver.py
>> 2011-05-17 14:14:20 UTC (rev 121687)
>> @@ -77,12 +77,16 @@
>> env = self._constructWSGIEnvironment(task)
>>
>> def start_response(status, headers, exc_info=None):
>> +if task.wroteResponseHeader() and not exc_info:
>> +raise AssertionError("start_response called a second time "
>> + "without providing exc_info.")
>> if exc_info:
>> try:
>> if task.wroteResponseHeader():
>> raise exc_info[0], exc_info[1], exc_info[2]
>> else:
>> -pass
>> +# As per WSGI spec existing headers must be cleared
>> +task.accumulated_headers = None
>> finally:
>> exc_info = None
>> # Prepare the headers for output
>> @@ -110,12 +114,16 @@
>> env['wsgi.handleErrors'] = False
>>
>> def start_response(status, headers, exc_info=None):
>> +if task.wroteResponseHeader() and not exc_info:
>> +raise AssertionError("start_response called a second time "
>> + "without providing exc_info.")
>> if exc_info:
>> try:
>> if task.wroteResponseHeader():
>> raise exc_info[0], exc_info[1], exc_info[2]
>> else:
>> -pass
>> +# As per WSGI spec existing headers must be cleared
>> +task.accumulated_headers = None
>> finally:
>> exc_info = None
>> # Prepare the headers for output
>
> I think AssertionError is the wrong type of exception here: it has
> "debugging / testing" semantics which seem inappropriate. I think we
> would be better of raising an instance of a WSGI-specific exception type
>
The WSGI PEP doesn't specify any WSGI specific exceptions.
- The sample CGI example that the PEP provides also raises an AssertionError
for this scenario:
http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
Also note that Paste's HTTP server (Paster) and CherryPy both raise
AssertionErrors for this scenario:
- Paste:
https://bitbucket.org/ianb/paste/src/4f5cfde87603/paste/httpserver.py#cl-166
- CherryPy:
http://www.cherrypy.org/browser/trunk/py2/cherrypy/wsgiserver/__init__.py#L2050
Can you clarify what you meant by a WSGI-specific exception type?
> Thanks for the careful testing!
>
>
>
> Tres.
> - --
> ===
> Tres Seaver +1 540-429-0999 tsea...@palladion.com
> Palladion Software "Excellence by Design"http://palladion.com
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk3Sm/gACgkQ+gerLs4ltQ7oVQCfa0vEWPcASmLdO2BDeEzoeI5j
> eZYAniT/BCbFojmKxjq0did6wXLmmmiG
> =udSc
> -END PGP SIGNATURE-
>
> ___
> Zope-Dev maillist - Zope-Dev@zope.org
> https://mail.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> https://mail.zope.org/mailman/listinfo/zope-announce
> https://mail.zope.org/mailman/listinfo/zope )
Satchidanand Haridas
Software Engineer, Zope Corporation
___
Zope-Dev maillist - Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )