Log in |
Using The Zope Debugger(created from Jim Fulton's presentation given at the 9th International Python Conference). The Debugger is your FriendSets up a request environment Simple tests Debugging Timing Profiling Simple testingYou can do simple tests: cd lib/python python import Zope Zope.debug('/manage_addFolder?id=foo', u='jim:123') You can use this mode with external debuggers like Wing and Komodo. Debugging with pdb Same as before, but add the python import Zope Zope.debug('/manage_addFolder?id=foo', u='jim:123', d=1) Breakpoints are preset to allow you to continue to predefined points of interest. Entry to publishing (just above) entry to application code Post-mortem debugging Use the import Zope Zope.debug('/manage_addFolder?id=foo', u='jim:123', pm=1) If there's an error, use pdb.pm: import pdb pdb.pm() Time execution Use python import Zope Zope.debug('/manage_main, u='jim:123', t=1) Executes once, to warm up, and then runs 100 times, computing average time. Includes publisher overhead. Can modify repeat count lamely: import ZPublihser.Test ZPublisher.Test.repeat_count=10 Using the Python profiler Supply the name of a statistics file via the import Zope Zope.debug('/manage_addFolder?id=foo',u='jim:123', p='prof.dat') import pstats s=pstats.Stats('prof.dat') s.print_stats() Setting request variables You can provide extra request variables via the Zope.debug('/manage_addFile?id=foo', u='jim:123',d=1, extra={'file': open('test.dat')} ) The .bobodb file Read when the Used to set breakpoints or set up "environment" data: import OFS.Folder breakpoints=(OFS.Folder.manage_addFolder, ) env={'rows': '20'} |