Re: SVN: zope.server/branches/achapman-exc-info/src/zope/server/http/ further compliance with WSGI PEP.

Tres Seaver <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
-----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

Thanks for the careful testing!



Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
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  -  [email protected]
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 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.