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

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


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

Modified Files:
      Tag: Zope-2_5-branch
	ApplicationManager.py 
Log Message:

      - Collector #670: applied patch from Dieter Maurer to enhance
        the Zope profiling support


=== Zope/lib/python/App/ApplicationManager.py 1.77 => 1.77.16.1 ===
--- Zope/lib/python/App/ApplicationManager.py:1.77	Wed Nov 28 10:50:52 2001
+++ Zope/lib/python/App/ApplicationManager.py	Wed Nov 13 05:30:54 2002
@@ -172,15 +172,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()