[Zope3-checkins] 
	SVN: Zope3/trunk/src/zope/app/traversing/namespace.py
	Provided two docstrings/doctests for debug adapter to allow separate
    Jim Fulton 
    jim at zope.com
       
    Tue Aug  3 10:06:16 EDT 2004
    
    
  
Log message for revision 26874:
  Provided two docstrings/doctests for debug adapter to allow separate
  tests with and without -O.  This is necessary to avoid a failure when
  -O is used.
  
Changed:
  U   Zope3/trunk/src/zope/app/traversing/namespace.py
-=-
Modified: Zope3/trunk/src/zope/app/traversing/namespace.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/namespace.py	2004-08-03 13:51:58 UTC (rev 26873)
+++ Zope3/trunk/src/zope/app/traversing/namespace.py	2004-08-03 14:06:15 UTC (rev 26874)
@@ -445,7 +445,7 @@
             >>> ob = object()
             >>> adapter = debug(ob, request)
 
-        ++debug++source enables source annotations
+        in debug mode, ++debug++source enables source annotations
 
             >>> request.debug.sourceAnnotations
             False
@@ -504,3 +504,53 @@
         else:
             raise ValueError("Debug flags only allowed in debug mode")
 
+    if not __debug__:
+        # If not in debug mode, we should get an error:
+        traverse.__doc__ = """Disabled debug traversal adapter
+
+        This adapter allows debugging flags to be set in the request,
+        but it is disabled because Python was run with -O.
+
+        Setup for demonstration:
+
+            >>> from zope.publisher.browser import TestRequest
+            >>> request = TestRequest()
+            >>> ob = object()
+            >>> adapter = debug(ob, request)
+
+        in debug mode, ++debug++source enables source annotations
+
+            >>> request.debug.sourceAnnotations
+            False
+            >>> adapter.traverse('source', ()) is ob
+            Traceback (most recent call last):
+            ...
+            ValueError: Debug flags only allowed in debug mode
+
+        ++debug++tal enables TAL markup in output
+
+            >>> request.debug.showTAL
+            False
+            >>> adapter.traverse('tal', ()) is ob
+            Traceback (most recent call last):
+            ...
+            ValueError: Debug flags only allowed in debug mode
+
+        ++debug++errors enables tracebacks (by switching to debug skin)
+
+            >>> request.getPresentationSkin()
+            'default'
+            >>> adapter.traverse('errors', ()) is ob
+            Traceback (most recent call last):
+            ...
+            ValueError: Debug flags only allowed in debug mode
+
+        You can specify several flags separated by commas
+
+            >>> adapter.traverse('source,tal', ()) is ob
+            Traceback (most recent call last):
+            ...
+            ValueError: Debug flags only allowed in debug mode
+        """
+
+        
    
    
More information about the Zope3-Checkins
mailing list