[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ApplicationControl/Views/Browser - RuntimeInfoView.py:1.1.2.1 __init__.py:1.1.2.1 browser.zcml:1.1.2.1 runtimeinfo.pt:1.1.2.1
Philipp von Weitershausen
philikon@gmx.net
Wed, 10 Apr 2002 05:15:18 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ApplicationControl/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv17624/Views/Browser
Added Files:
Tag: Zope-3x-branch
RuntimeInfoView.py __init__.py browser.zcml runtimeinfo.pt
Log Message:
Added default view for ApplicationController showing runtime information,
accessible through /ApplicationController;etc
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/Views/Browser/RuntimeInfoView.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.
#
##############################################################################
"""Define runtime information view component for Application Control
$Id: RuntimeInfoView.py,v 1.1.2.1 2002/04/10 09:15:17 philikon Exp $
"""
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.App.OFS.ApplicationControl.IRuntimeInfo import IRuntimeInfo
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.ComponentArchitecture import getAdapter
class RuntimeInfoView(AttributePublisher):
def __init__(self, context):
self._context = context
def getContext(self):
return self._context
def runtimeInfo(self):
runtime_info = getAdapter(self.getContext(), IRuntimeInfo) # XXX what are we going to do if this fails???
formatted = {} # contains formatted 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 = PageTemplateFile('runtimeinfo.pt')
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/Views/Browser/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/Views/Browser/browser.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:security='http://namespaces.zope.org/security'
xmlns:browser='http://namespaces.zope.org/browser'
>
<!-- ApplicationControl View Directives -->
<browser:defaultView name="runtimeinfo"
for="Zope.App.OFS.ApplicationControl.IApplicationControl."
factory=".RuntimeInfoView." />
<security:protectClass
name=".RuntimeInfoView."
permission_id="Zope.ManageApplication"
methods="index, runtimeInfo" />
</zopeConfigure>
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/Views/Browser/runtimeinfo.pt ===
<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>
</ul>
</div>
</body>
</html>