[Zope3-checkins] CVS: Zope3/src/zope/app/browser/applicationcontrol - zodbcontrol.pt:1.1 zodbcontrol.py:1.1 zodbcontrol.pyc:1.1 configure.zcml:1.5 runtimeinfo.py:1.4 servercontrol.py:1.5
Stephan Richter
srichter@cosmos.phy.tufts.edu
Thu, 31 Jul 2003 17:38:05 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/applicationcontrol
In directory cvs.zope.org:/tmp/cvs-serv12920/browser/applicationcontrol
Modified Files:
configure.zcml runtimeinfo.py servercontrol.py
Added Files:
zodbcontrol.pt zodbcontrol.py zodbcontrol.pyc
Log Message:
- Added ZODB Control. You can now see the size of the ZODB and pack it the
usual way, specifying the number of days that should be preserved.
- Cleaned up the crufty ApplicationControl code a bit to the latest
practices and cleaned up whitespace stuff.
=== Added File Zope3/src/zope/app/browser/applicationcontrol/zodbcontrol.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title>ZODB Controller</title>
</head>
<body>
<div metal:fill-slot="body">
<div style="font-size: 120%">
Size of file: <em tal:content="view/getDatabaseSize">1.1 MB</em>
</div>
<p tal:define="status view/pack"
tal:condition="status"
tal:content="status" />
<form action="." method="POST" tal:attributes="action request/URL">
<div class="row">
<div class="label">Keep up to:</div>
<div class="view">
<input type="text" size="4" name="days" value="0"/> days
</div>
</div>
<div class="row">
<div class="control">
<input type="submit" name="PACK" value="Pack" />
</div>
</div>
</form>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/browser/applicationcontrol/zodbcontrol.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Server Control View
$Id: zodbcontrol.py,v 1.1 2003/07/31 21:37:27 srichter Exp $
"""
from zodb.storage.file.errors import FileStorageError
from zope.app.i18n import ZopeMessageIDFactory as _
from zope.app.interfaces.applicationcontrol import IZODBControl
from zope.component import getAdapter
class ZODBControlView:
def getDatabaseSize(self):
zodbcontrol = getAdapter(self.context, IZODBControl)
size = zodbcontrol.getDatabaseSize(
self.request.publication.db)
if size > 1024**2:
return "%.1f MB" %(float(size)/1024**2)
elif size > 1024:
return "%.1f kB" %(float(size)/1024)
else:
return "%i Bytes" %size
def pack(self):
"""Do the packing!"""
status = ''
if 'PACK' in self.request:
zodbcontrol = getAdapter(self.context, IZODBControl)
try:
zodbcontrol.pack(self.request.publication.db,
int(self.request.get('days', 0)))
status = _('ZODB successfully packed.')
except FileStorageError, err:
status = _(err)
return status
=== Added File Zope3/src/zope/app/browser/applicationcontrol/zodbcontrol.pyc ===
<Binary-ish file>
=== Zope3/src/zope/app/browser/applicationcontrol/configure.zcml 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/applicationcontrol/configure.zcml:1.4 Tue Dec 31 13:26:50 2002
+++ Zope3/src/zope/app/browser/applicationcontrol/configure.zcml Thu Jul 31 17:37:27 2003
@@ -1,35 +1,34 @@
<zopeConfigure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:browser='http://namespaces.zope.org/browser'
- xmlns:application-control='http://namespaces.zope.org/application-control'
->
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
<!-- ServerControl View Directives -->
<browser:pages
- for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl"
+ for="zope.app.interfaces.applicationcontrol.IApplicationControl"
permission="zope.ManageApplication"
- class="zope.app.browser.applicationcontrol.servercontrol.ServerControlView">
+ class=
+ "zope.app.browser.applicationcontrol.servercontrol.ServerControlView">
- <browser:page name="ServerControlForm.html" attribute="index" />
- <browser:page name="ServerControl.html" attribute="action" />
+ <browser:page name="ServerControlForm.html" template="server-control.pt"
+ menu="zmi_views" title="Server Control" />
+ <browser:page name="ServerControl.html" attribute="action" />
</browser:pages>
-
- <browser:menuItem
- for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl"
- menu="zmi_views"
- action="ServerControlForm.html"
- title="Server control"
- />
-
<browser:page
- for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl"
+ for="zope.app.interfaces.applicationcontrol.IApplicationControl"
name="index.html"
menu="zmi_views"
title="Runtime Information"
- attribute="index"
+ template="runtimeinfo.pt"
class="zope.app.browser.applicationcontrol.runtimeinfo.RuntimeInfoView"
+ permission="zope.ManageApplication"/>
+
+ <browser:page
+ for="zope.app.interfaces.applicationcontrol.IApplicationControl"
+ name="ZODBControl.html"
+ template="zodbcontrol.pt"
+ class="zope.app.browser.applicationcontrol.zodbcontrol.ZODBControlView"
permission="zope.ManageApplication"
- />
+ menu="zmi_views" title="ZODB Control"/>
</zopeConfigure>
=== Zope3/src/zope/app/browser/applicationcontrol/runtimeinfo.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/applicationcontrol/runtimeinfo.py:1.3 Tue Apr 8 16:35:25 2003
+++ Zope3/src/zope/app/browser/applicationcontrol/runtimeinfo.py Thu Jul 31 17:37:27 2003
@@ -15,15 +15,12 @@
$Id$
"""
-
-from zope.publisher.browser import BrowserView
-from zope.app.interfaces.applicationcontrol.runtimeinfo import IRuntimeInfo
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.app.interfaces.applicationcontrol import IRuntimeInfo
from zope.component import getAdapter
from zope.component import ComponentLookupError
-class RuntimeInfoView(BrowserView):
+class RuntimeInfoView:
def runtimeInfo(self):
formatted = {} # will contain formatted runtime information
@@ -33,7 +30,8 @@
formatted['ZopeVersion'] = runtime_info.getZopeVersion()
formatted['PythonVersion'] = runtime_info.getPythonVersion()
formatted['PythonPath'] = runtime_info.getPythonPath()
- formatted['SystemPlatform'] = " ".join(runtime_info.getSystemPlatform())
+ formatted['SystemPlatform'] = " ".join(
+ runtime_info.getSystemPlatform())
formatted['CommandLine'] = " ".join(runtime_info.getCommandLine())
formatted['ProcessId'] = runtime_info.getProcessId()
@@ -66,7 +64,5 @@
formatted['Uptime'] = "N/A"
formatted['Hint'] = "Could not retrieve runtime information."
-
return formatted
- index = ViewPageTemplateFile('runtimeinfo.pt')
=== Zope3/src/zope/app/browser/applicationcontrol/servercontrol.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/applicationcontrol/servercontrol.py:1.4 Tue Apr 8 17:44:33 2003
+++ Zope3/src/zope/app/browser/applicationcontrol/servercontrol.py Thu Jul 31 17:37:27 2003
@@ -11,19 +11,16 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-__doc__ = """ Server Control View
+""" Server Control View
-$Id$ """
-
-from zope.publisher.browser import BrowserView
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.interfaces.applicationcontrol.servercontrol \
- import IServerControl
+$Id$
+"""
+from zope.app.interfaces.applicationcontrol import IServerControl
from zope.component import getUtility
from zope.app.i18n import ZopeMessageIDFactory as _
-class ServerControlView(BrowserView):
+class ServerControlView:
def serverControl(self):
# XXX Refactor alarm! This is *required*. We really
@@ -40,5 +37,3 @@
elif 'shutdown' in self.request:
return (self.serverControl().shutdown()
or _("You shut down the server."))
-
- index = ViewPageTemplateFile('server-control.pt')