[Zope-dev] Unauthorized handling in Zope2

yuppie y.2010 at wcm-solutions.de
Tue Apr 20 03:51:39 EDT 2010


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__



More information about the Zope-Dev mailing list