[Zope3-checkins] CVS: Zope3/src/zope/app/browser/applicationcontrol - __init__.py:1.2 configure.zcml:1.2 runtimeinfo.pt:1.2 runtimeinfo.py:1.2 server-control.pt:1.2 servercontrol.py:1.2
Jim Fulton
jim@zope.com
Wed, 25 Dec 2002 09:13:58 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/applicationcontrol
In directory cvs.zope.org:/tmp/cvs-serv15352/src/zope/app/browser/applicationcontrol
Added Files:
__init__.py configure.zcml runtimeinfo.pt runtimeinfo.py
server-control.pt servercontrol.py
Log Message:
Grand renaming:
- Renamed most files (especially python modules) to lower case.
- Moved views and interfaces into separate hierarchies within each
project, where each top-level directory under the zope package
is a separate project.
- Moved everything to src from lib/python.
lib/python will eventually go away. I need access to the cvs
repository to make this happen, however.
There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.
=== Zope3/src/zope/app/browser/applicationcontrol/__init__.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:13:58 2002
+++ Zope3/src/zope/app/browser/applicationcontrol/__init__.py Wed Dec 25 09:12:27 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.
=== Zope3/src/zope/app/browser/applicationcontrol/configure.zcml 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:13:58 2002
+++ Zope3/src/zope/app/browser/applicationcontrol/configure.zcml Wed Dec 25 09:12:27 2002
@@ -0,0 +1,40 @@
+<zopeConfigure
+ xmlns='http://namespaces.zope.org/zope'
+ xmlns:browser='http://namespaces.zope.org/browser'
+ xmlns:application-control='http://namespaces.zope.org/application-control'
+>
+
+ <!-- ServerControl View Directives -->
+ <browser:view
+ for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl"
+ permission="zope.ManageApplication"
+ factory="zope.app.browser.applicationcontrol.servercontrol.ServerControlView">
+
+ <browser:page name="ServerControlForm.html" attribute="index" />
+ <browser:page name="ServerControl.html" attribute="action" />
+ </browser:view>
+
+
+ <browser:menuItem
+ for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl"
+ menu="zmi_views"
+ action="ServerControlForm.html"
+ title="Server control"
+ />
+
+ <browser:view
+ for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl"
+ factory="zope.app.browser.applicationcontrol.runtimeinfo.RuntimeInfoView"
+ permission="zope.ManageApplication" >
+
+ <browser:page name="index.html" attribute="index" />
+ </browser:view>
+
+ <browser:menuItem
+ for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl"
+ menu="zmi_views"
+ action="index.html"
+ title="Runtime Information"
+ />
+
+</zopeConfigure>
=== Zope3/src/zope/app/browser/applicationcontrol/runtimeinfo.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:13:58 2002
+++ Zope3/src/zope/app/browser/applicationcontrol/runtimeinfo.pt Wed Dec 25 09:12:27 2002
@@ -0,0 +1,27 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+<title>Zope Runtime Information</title>
+</head>
+<body>
+<div metal:fill-slot="body">
+
+<ul tal:define="runtime_info view/runtimeInfo">
+ <li>Zope version: <span tal:replace="runtime_info/ZopeVersion" />
+ <li>Python version: <span tal:replace="runtime_info/PythonVersion" />
+ <li>System platform: <span tal:replace="runtime_info/SystemPlatform" />
+ <li>Command line: <span tal:replace="runtime_info/CommandLine" />
+ <li>Process id: <span tal:replace="runtime_info/ProcessId" />
+ <li>Uptime: <span tal:replace="runtime_info/Uptime" />
+ <li>Python path:</li>
+ <ul>
+ <li tal:repeat="path runtime_info/PythonPath" tal:content="path">path</li>
+ </ul>
+ <!-- # XXX UI folks: following line want's special attention. The hardcoding should
+ be removed someday. -->
+ <li tal:condition="runtime_info/Hint | nothing" style="color:red;"
+ tal:content="runtime_info/Hint" />
+</ul>
+
+</div>
+</body>
+</html>
=== Zope3/src/zope/app/browser/applicationcontrol/runtimeinfo.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:13:58 2002
+++ Zope3/src/zope/app/browser/applicationcontrol/runtimeinfo.py Wed Dec 25 09:12:27 2002
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Define runtime information view component for Application Control
+
+$Id$
+"""
+
+from zope.publisher.browser import BrowserView
+from zope.app.interfaces.applicationcontrol.runtimeinfo import IRuntimeInfo
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.component import getAdapter
+from zope.component import ComponentLookupError
+
+
+class RuntimeInfoView(BrowserView):
+
+ def runtimeInfo(self):
+ formatted = {} # will contain formatted runtime information
+
+ try:
+ runtime_info = getAdapter(self.context, IRuntimeInfo)
+ except ComponentLookupError:
+ # XXX We avoid having errors in the ApplicationController,
+ # because all those things need to stay accessible.
+ # Everybody ok with that?
+ formatted['ZopeVersion'] = "N/A"
+ formatted['PythonVersion'] = "N/A"
+ formatted['PythonPath'] = "N/A"
+ formatted['SystemPlatform'] = "N/A"
+ formatted['CommandLine'] = "N/A"
+ formatted['ProcessId'] = "N/A"
+ formatted['Hint'] = "Could not retrieve runtime information."
+
+ formatted['ZopeVersion'] = runtime_info.getZopeVersion()
+ formatted['PythonVersion'] = runtime_info.getPythonVersion()
+ formatted['PythonPath'] = runtime_info.getPythonPath()
+ formatted['SystemPlatform'] = " ".join(runtime_info.getSystemPlatform())
+ formatted['CommandLine'] = " ".join(runtime_info.getCommandLine())
+ formatted['ProcessId'] = runtime_info.getProcessId()
+
+ # make a unix "uptime" uptime format
+ uptime = runtime_info.getUptime()
+ days = int(uptime / (60*60*24))
+ uptime = uptime - days * (60*60*24)
+
+ hours = int(uptime / (60*60))
+ uptime = uptime - hours * (60*60)
+
+ minutes = int(uptime / 60)
+ uptime = uptime - minutes * 60
+
+ seconds = uptime
+ formatted['Uptime'] = "%s%02d:%02d:%02d" % (
+ ((days or "") and "%d days, " % days), hours, minutes, seconds)
+
+ return formatted
+
+ index = ViewPageTemplateFile('runtimeinfo.pt')
=== Zope3/src/zope/app/browser/applicationcontrol/server-control.pt 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:13:58 2002
+++ Zope3/src/zope/app/browser/applicationcontrol/server-control.pt Wed Dec 25 09:12:27 2002
@@ -0,0 +1,15 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+<title>Zope Stub Server Controller</title>
+</head>
+<body>
+<div metal:fill-slot="body">
+
+ <form name="servercontrol" action="ServerControl.html" method="post">
+ <input type="submit" name="restart" value="Restart server" /> <br />
+ <input type="submit" name="shutdown" value="Shutdown server" /> <br />
+ </form>
+
+</div>
+</body>
+</html>
=== Zope3/src/zope/app/browser/applicationcontrol/servercontrol.py 1.1 => 1.2 ===
--- /dev/null Wed Dec 25 09:13:58 2002
+++ Zope3/src/zope/app/browser/applicationcontrol/servercontrol.py Wed Dec 25 09:12:27 2002
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+__doc__ = """ 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
+from zope.component import getUtility
+
+
+class ServerControlView(BrowserView):
+
+ def serverControl(self):
+ # XXX Refactor alarm! This is *required*. We really
+ # rely on it being there. If it was a utility,
+ # we wouldn't care, if the ServerControl is gone,
+ # but actually we do. Maybe this should be a service ...
+ return getUtility(self.context, IServerControl)
+
+ def action(self):
+ """Do the shutdown/restart!"""
+ if 'restart' in self.request:
+ return (self.serverControl().restart()
+ or "You restarted the server.")
+ elif 'shutdown' in self.request:
+ return (self.serverControl().shutdown()
+ or "You shut down the server.")
+
+ index = ViewPageTemplateFile('server-control.pt')