[Zope3-checkins] SVN: Zope3/trunk/ Added another debugging flag,
++debug++errors. It turns on tracebacks in your
Marius Gedminas
marius at pov.lt
Sat Jun 12 08:35:50 EDT 2004
Log message for revision 25386:
Added another debugging flag, ++debug++errors. It turns on tracebacks in your
browser window when errors occur.
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2004-06-12 12:23:15 UTC (rev 25385)
+++ Zope3/trunk/doc/CHANGES.txt 2004-06-12 12:35:50 UTC (rev 25386)
@@ -11,7 +11,7 @@
New features
- Added ++debug++ traversal adapter that allows you to turn on debugging
- flags in request.debug. Currently there are two debug flags:
+ flags in request.debug. Currently the following flags are defined:
+ "source" adds HTML comments to rendered page templates showing
where each code snippet came from.
@@ -19,7 +19,9 @@
+ "tal" leaves TAL/METAL markup in rendered page templates allowing
you to see how it was generated.
- Try http://localhost:8080/++debug++source,tal/@@contents.html
+ + "errors" shows full tracebacks when a system error occurs.
+
+ Try e.g. http://localhost:8080/++debug++source,tal/@@contents.html
and view the source of the resulting page.
Restructuring
Modified: Zope3/trunk/src/zope/app/traversing/namespace.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/namespace.py 2004-06-12 12:23:15 UTC (rev 25385)
+++ Zope3/trunk/src/zope/app/traversing/namespace.py 2004-06-12 12:35:50 UTC (rev 25386)
@@ -439,29 +439,56 @@
def traverse(self, name, ignored):
"""Debug traversal adapter
- This adapter allows debugging flags to be set in the request.
- See IDebugFlags.
+ This adapter allows debugging flags to be set in the request.
+ See IDebugFlags.
- Demonstration:
+ Setup for demonstration:
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> ob = object()
- >>> adapter = debug(ob, request)
- >>> request.debug.sourceAnnotations
- False
- >>> adapter.traverse('source', ()) is ob
- True
- >>> request.debug.sourceAnnotations
- True
- >>> adapter.traverse('source,tal', ()) is ob
- True
- >>> try:
- ... adapter.traverse('badflag', ())
- ... except ValueError:
- ... print 'unknown debugging flag'
- unknown debugging flag
+ >>> from zope.publisher.browser import TestRequest
+ >>> request = TestRequest()
+ >>> ob = object()
+ >>> adapter = debug(ob, request)
+ ++debug++source enables source annotations
+
+ >>> request.debug.sourceAnnotations
+ False
+ >>> adapter.traverse('source', ()) is ob
+ True
+ >>> request.debug.sourceAnnotations
+ True
+
+ ++debug++tal enables TAL markup in output
+
+ >>> request.debug.showTAL
+ False
+ >>> adapter.traverse('tal', ()) is ob
+ True
+ >>> request.debug.showTAL
+ True
+
+ ++debug++errors enables tracebacks (by switching to debug skin)
+
+ >>> request.getPresentationSkin()
+ 'default'
+ >>> adapter.traverse('errors', ()) is ob
+ True
+ >>> request.getPresentationSkin()
+ 'Debug'
+
+ You can specify several flags separated by commas
+
+ >>> adapter.traverse('source,tal', ()) is ob
+ True
+
+ Unknown flag names cause exceptions
+
+ >>> try:
+ ... adapter.traverse('badflag', ())
+ ... except ValueError:
+ ... print 'unknown debugging flag'
+ unknown debugging flag
+
"""
if __debug__:
request = self.request
@@ -470,6 +497,11 @@
request.debug.sourceAnnotations = True
elif flag == 'tal':
request.debug.showTAL = True
+ elif flag == 'errors':
+ # XXX I am not sure this is the best solution. What
+ # if we want to enable tracebacks when also trying to
+ # debug a different skin?
+ request.setPresentationSkin('Debug')
else:
raise ValueError("Unknown debug flag: %s" % flag)
return self.context
More information about the Zope3-Checkins
mailing list