[Zope-Checkins] SVN: Zope/trunk/ LP #142502: Added a knob to the Debug control panel to reset profile data.

Tres Seaver tseaver at palladion.com
Wed Apr 7 21:34:40 EDT 2010


Log message for revision 110627:
  LP #142502:  Added a knob to the Debug control panel to reset profile data.
  
  Thanks to Vladimir Patukhov for the patch.  
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/App/ApplicationManager.py
  U   Zope/trunk/src/App/dtml/profile.dtml
  U   Zope/trunk/src/App/tests/test_ApplicationManager.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2010-04-08 01:22:36 UTC (rev 110626)
+++ Zope/trunk/doc/CHANGES.rst	2010-04-08 01:34:39 UTC (rev 110627)
@@ -100,6 +100,9 @@
 Features Added
 ++++++++++++++
 
+- LP #142502:  Added a knob to the Debug control panel for resetting
+  profile data.  Thanks to Vladimir Patukhov for the patch.
+
 - LP #143232: Added option to 'zope.conf' to specify an additional directory
   to be searched for 'App.Extensions' lookups.  Thanks to Rodrigo Senra for
   the patch.

Modified: Zope/trunk/src/App/ApplicationManager.py
===================================================================
--- Zope/trunk/src/App/ApplicationManager.py	2010-04-08 01:22:36 UTC (rev 110626)
+++ Zope/trunk/src/App/ApplicationManager.py	2010-04-08 01:34:39 UTC (rev 110627)
@@ -39,6 +39,7 @@
 from Product import ProductFolder
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from zExceptions import Redirect
+from ZPublisher import Publish
 
 LOG = getLogger('ApplicationManager')
 
@@ -252,6 +253,11 @@
         sys.stdout = stdout
         return output.getvalue()
 
+    def manage_profile_reset(self):
+        """ Reset profile data
+        """
+        Publish._pstat = sys._ps_ = None
+
     def manage_getSysPath(self):
         return list(sys.path)
 

Modified: Zope/trunk/src/App/dtml/profile.dtml
===================================================================
--- Zope/trunk/src/App/dtml/profile.dtml	2010-04-08 01:22:36 UTC (rev 110626)
+++ Zope/trunk/src/App/dtml/profile.dtml	2010-04-08 01:34:39 UTC (rev 110627)
@@ -1,6 +1,16 @@
 <dtml-var manage_page_header>
 <dtml-var manage_tabs>
 
+<dtml-if "REQUEST.get('reset')">
+
+<dtml-call "manage_profile_reset()">
+<br />
+<div class="form-text">
+Profiling data was reset.
+</div>
+
+<dtml-else>
+
 <dtml-let sort="REQUEST.get('sort', 'time')"
           limit="REQUEST.get('limit', 100)" 
           mode="REQUEST.get('mode', 'stats')" 
@@ -50,6 +60,8 @@
 </td>
 <td>
 <input type="submit" name="submit" value="Update">
+&nbsp;
+<input type="submit" name="reset" value="Reset data">
 </td>
 </tr>
 </table>
@@ -71,4 +83,6 @@
 </dtml-if>
 </dtml-let>
 
+</dtml-if>
+
 <dtml-var manage_page_footer>

Modified: Zope/trunk/src/App/tests/test_ApplicationManager.py
===================================================================
--- Zope/trunk/src/App/tests/test_ApplicationManager.py	2010-04-08 01:22:36 UTC (rev 110626)
+++ Zope/trunk/src/App/tests/test_ApplicationManager.py	2010-04-08 01:34:39 UTC (rev 110627)
@@ -239,6 +239,23 @@
     #def test_dbconnections(self):  XXX -- TOO UGLY TO TEST
     #def test_manage_profile_stats(self):  XXX -- TOO UGLY TO TEST
 
+    def test_manage_profile_reset(self):
+        import sys
+        from ZPublisher import Publish
+        _old_sys__ps_ = getattr(sys, '_ps_', self)
+        _old_Publish_pstat = getattr(Publish, '_pstat', self)
+        sys._ps_ = Publish._pstat = object()
+        try:
+            dm = self._makeOne('test')
+            dm.manage_profile_reset()
+        finally:
+            if _old_sys__ps_ is not self:
+                sys._ps_ = _old_sys__ps_
+            if _old_Publish_pstat is not self:
+                Publish._pstat = _old_Publish_pstat
+        self.failUnless(sys._ps_ is None)
+        self.failUnless(Publish._pstat is None)
+
     def test_manage_getSysPath(self):
         import sys
         dm = self._makeOne('test')



More information about the Zope-Checkins mailing list