[Zope-Checkins] CVS: Zope/lib/python/App - ApplicationManager.py:1.84

Andreas Jung andreas@andreas-jung.com
Wed, 13 Nov 2002 05:27:48 -0500


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

Modified Files:
	ApplicationManager.py 
Log Message:
      - Collector #670: applied patch from Dieter Maurer to enhance
        the Zope profiling support


=== Zope/lib/python/App/ApplicationManager.py 1.83 => 1.84 ===
--- Zope/lib/python/App/ApplicationManager.py:1.83	Tue Nov 12 12:19:13 2002
+++ Zope/lib/python/App/ApplicationManager.py	Wed Nov 13 05:27:18 2002
@@ -176,15 +176,19 @@
 
     manage_profile=DTMLFile('dtml/profile', globals())
 
-    def manage_profile_stats(self, sort='time', limit=200):
+    def manage_profile_stats(self, sort='time', limit=200, stripDirs=1, mode='stats'):
         """Return profile data if available"""
         stats=getattr(sys, '_ps_', None)
         if stats is None:
             return None
         output=StringIO()
         stdout=sys.stdout
+        if stripDirs:
+            from copy import copy; stats= copy(stats)
+            stats.strip_dirs()
+        stats.sort_stats(sort)
         sys.stdout=output
-        stats.strip_dirs().sort_stats(sort).print_stats(limit)
+        getattr(stats,'print_%s' % mode)(limit)
         sys.stdout.flush()
         sys.stdout=stdout
         return output.getvalue()