Re: Unauthorized handling in Zope2

yuppie <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
Hi!


Wichert Akkerman wrote:
> v is the html as generated by my view. Reraising the exception transfers
> control to the bare except in
> ZPublisher.Publish.publish_module_standard, which generates the standard
> site error page and returns that.

Could it be that your v is unicode?

Please let me know if the attached patch fixes the issue.


Cheers,

	Yuppie



Index: public/src/zExceptions/unauthorized.py
===================================================================
--- public/src/zExceptions/unauthorized.py	(revision 111162)
+++ public/src/zExceptions/unauthorized.py	(working copy)
@@ -43,7 +43,7 @@
          provides are added to needed.
          """
          if name is None and (
-            not isinstance(message, StringType) or len(message.split()) 
<= 1):
+            not isinstance(message, basestring) or len(message.split()) 
<= 1):
              # First arg is a name, not a message
              name=message
              message=None
Index: public/src/ZPublisher/HTTPResponse.py
===================================================================
--- public/src/ZPublisher/HTTPResponse.py	(revision 111162)
+++ public/src/ZPublisher/HTTPResponse.py	(working copy)
@@ -800,7 +800,10 @@
          b = v
          if isinstance(b, Exception):
              try:
-                b = str(b)
+                try:
+                    b = str(b)
+                except UnicodeEncodeError:
+                    b = self._encode_unicode(unicode(b))
              except:
                  b = '<unprintable %s object>' % type(b).__name__

_______________________________________________
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.