Commit a6ad3081 authored by Tres Seaver's avatar Tres Seaver

LP #142502: Added a knob to the Debug control panel to reset profile data.

Thanks to Vladimir Patukhov for the patch.  
parent ae6112d7
...@@ -100,6 +100,9 @@ Restructuring ...@@ -100,6 +100,9 @@ Restructuring
Features Added 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 - LP #143232: Added option to 'zope.conf' to specify an additional directory
to be searched for 'App.Extensions' lookups. Thanks to Rodrigo Senra for to be searched for 'App.Extensions' lookups. Thanks to Rodrigo Senra for
the patch. the patch.
......
...@@ -39,6 +39,7 @@ from OFS.SimpleItem import SimpleItem ...@@ -39,6 +39,7 @@ from OFS.SimpleItem import SimpleItem
from Product import ProductFolder from Product import ProductFolder
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from zExceptions import Redirect from zExceptions import Redirect
from ZPublisher import Publish
LOG = getLogger('ApplicationManager') LOG = getLogger('ApplicationManager')
...@@ -252,6 +253,11 @@ class DebugManager(Item, Implicit): ...@@ -252,6 +253,11 @@ class DebugManager(Item, Implicit):
sys.stdout = stdout sys.stdout = stdout
return output.getvalue() return output.getvalue()
def manage_profile_reset(self):
""" Reset profile data
"""
Publish._pstat = sys._ps_ = None
def manage_getSysPath(self): def manage_getSysPath(self):
return list(sys.path) return list(sys.path)
......
<dtml-var manage_page_header> <dtml-var manage_page_header>
<dtml-var manage_tabs> <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')" <dtml-let sort="REQUEST.get('sort', 'time')"
limit="REQUEST.get('limit', 100)" limit="REQUEST.get('limit', 100)"
mode="REQUEST.get('mode', 'stats')" mode="REQUEST.get('mode', 'stats')"
...@@ -50,6 +60,8 @@ Python profiler documentation</a>. ...@@ -50,6 +60,8 @@ Python profiler documentation</a>.
</td> </td>
<td> <td>
<input type="submit" name="submit" value="Update"> <input type="submit" name="submit" value="Update">
&nbsp;
<input type="submit" name="reset" value="Reset data">
</td> </td>
</tr> </tr>
</table> </table>
...@@ -71,4 +83,6 @@ used to dump a profile report when the process restarts or exits. ...@@ -71,4 +83,6 @@ used to dump a profile report when the process restarts or exits.
</dtml-if> </dtml-if>
</dtml-let> </dtml-let>
</dtml-if>
<dtml-var manage_page_footer> <dtml-var manage_page_footer>
...@@ -239,6 +239,23 @@ class DebugManagerTests(unittest.TestCase): ...@@ -239,6 +239,23 @@ class DebugManagerTests(unittest.TestCase):
#def test_dbconnections(self): XXX -- TOO UGLY TO TEST #def test_dbconnections(self): XXX -- TOO UGLY TO TEST
#def test_manage_profile_stats(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): def test_manage_getSysPath(self):
import sys import sys
dm = self._makeOne('test') dm = self._makeOne('test')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment