[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zope-cvs
Subject:    [Zope-Checkins] CVS: Zope/lib/python/OFS - SimpleItem.py:1.103
From:       Casey Duncan <casey () zope ! com>
Date:       2002-08-30 18:29:59
[Download RAW message or body]

Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv28127/lib/python/OFS

Modified Files:
	SimpleItem.py 
Log Message:
Refactored error message handling so that SimpleItem's raise_standardErrorMessage \
sniffs the response to see if it wants an html encoded error message or not.

If so, then standard_error_message is rendered as usual as the error value. Otherwise \
the error value text is passed through unchanged.

XML-RPC responses now request text/plain error format so that standard_error_message \
is not envoked to render the fault string. Because of this, the previous formatting \
code could be removed, although html tags are still stripped because error values \
themselves sometimes contain tags 8^/


=== Zope/lib/python/OFS/SimpleItem.py 1.102 => 1.103 ===
--- Zope/lib/python/OFS/SimpleItem.py:1.102	Wed Aug 14 17:42:56 2002
+++ Zope/lib/python/OFS/SimpleItem.py	Fri Aug 30 14:29:57 2002
@@ -190,37 +190,41 @@
             if client is None: client=self
             if not REQUEST: REQUEST=self.aq_acquire('REQUEST')
 
-            try:
-                if hasattr(client, 'standard_error_message'):
-                    s=getattr(client, 'standard_error_message')
-                else:
-                    client = client.aq_parent
-                    s=getattr(client, 'standard_error_message')
-                kwargs = {'error_type': error_type,
-                          'error_value': error_value,
-                          'error_tb': error_tb,
-                          'error_traceback': error_tb,
-                          'error_message': error_message,
-                          'error_log_url': error_log_url}
-
-                if isinstance(s, HTML):
-                    v = s(client, REQUEST, **kwargs)
-                elif callable(s):
-                    v = s(**kwargs)
-                else:
-                    v = HTML.__call__(s, client, REQUEST, **kwargs)
-            except:
-                LOG('OFS', BLATHER,
-                    'Exception while rendering an error message',
-                    error=sys.exc_info())
+            if REQUEST.RESPONSE._error_format == 'text/html':
                 try:
-                    strv = str(error_value)
+                    if hasattr(client, 'standard_error_message'):
+                        s=getattr(client, 'standard_error_message')
+                    else:
+                        client = client.aq_parent
+                        s=getattr(client, 'standard_error_message')
+                    kwargs = {'error_type': error_type,
+                              'error_value': error_value,
+                              'error_tb': error_tb,
+                              'error_traceback': error_tb,
+                              'error_message': error_message,
+                              'error_log_url': error_log_url}
+
+                    if isinstance(s, HTML):
+                        v = s(client, REQUEST, **kwargs)
+                    elif callable(s):
+                        v = s(**kwargs)
+                    else:
+                        v = HTML.__call__(s, client, REQUEST, **kwargs)
                 except:
-                    strv = '<unprintable %s object>' % \
                str(type(error_value).__name__)
-                v = strv + (
-                    " (Also, an error occurred while attempting "
-                    "to render the standard error message.)")
-            raise error_type, v, tb
+                    LOG('OFS', BLATHER,
+                        'Exception while rendering an error message',
+                        error=sys.exc_info())
+                    try:
+                        strv = str(error_value)
+                    except:
+                        strv = ('<unprintable %s object>' % 
+                                str(type(error_value).__name__))
+                    v = strv + (
+                        " (Also, an error occurred while attempting "
+                        "to render the standard error message.)")
+                raise error_type, v, tb
+            else:
+                raise error_type, error_value, tb
         finally:
             if hasattr(self, '_v_eek'): del self._v_eek
             tb=None


_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://lists.zope.org/mailman/listinfo/zope-checkins


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic