[Zope-dev] Re: Patch for more meaningful SiterErrorLog

Evan Simpson evan@4-am.com
Mon, 07 Apr 2003 10:29:15 -0500


This is a multi-part message in MIME format.
--------------000009060800000404040302
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Casey Duncan wrote:
> It seems reasonable to me to single this one out since its so common.

I've been using the attached patch for a while... it provides a bit more 
information about exactly where the request went wrong, by marking the 
un-traversed segment of the URL.

Cheers,

Evan @ 4-am

--------------000009060800000404040302
Content-Type: text/plain;
 name="p"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="p"

Index: lib/python/Products/SiteErrorLog/SiteErrorLog.py
===================================================================
RCS file: /cvs-repository/Releases/Zope/lib/python/Products/SiteErrorLog/SiteErrorLog.py,v
retrieving revision 1.11.4.1
diff -u -r1.11.4.1 SiteErrorLog.py
--- lib/python/Products/SiteErrorLog/SiteErrorLog.py	16 Oct 2002 21:34:36 -0000	1.11.4.1
+++ lib/python/Products/SiteErrorLog/SiteErrorLog.py	7 Apr 2003 15:28:49 -0000
@@ -151,6 +151,10 @@
                 username = None
                 userid   = None
                 req_html = None
+                try:
+                    strv = str(info[1])
+                except:
+                    strv = '<unprintable %s object>' % str(type(info[1]).__name__)
                 if request:
                     url = request.get('URL', '?')
                     usr = getSecurityManager().getUser()
@@ -160,11 +164,13 @@
                         req_html = str(request)
                     except:
                         pass
-
-                try:
-                    strv = str(info[1])
-                except:
-                    strv = '<unprintable %s object>' % str(type(info[1]).__name__)
+                    if strtype == 'NotFound':
+                        strv = url
+                        next = request['TraversalRequestNameStack']
+                        if next:
+                            next = list(next)
+                            next.reverse()
+                            strv = '%s [ /%s ]' % (strv, '/'.join(next))
 
                 log = self._getLog()
                 entry_id = str(now) + str(random()) # Low chance of collision

--------------000009060800000404040302--