[Zope3-checkins] CVS: Zope3/src/zope/app/applicationcontrol/browser
- __init__.py:1.1 configure.zcml:1.1
globaltranslationservicecontrol.pt:1.1
globaltranslationservicecontrol.py:1.1 runtimeinfo.pt:1.1
runtimeinfo.py:1.1 server-control.pt:1.1 servercontrol.py:1.1
zodbcontrol.pt:1.1 zodbcontrol.py:1.1
Philipp von Weitershausen
philikon at philikon.de
Mon Mar 1 08:43:26 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/applicationcontrol/browser
In directory cvs.zope.org:/tmp/cvs-serv19445/applicationcontrol/browser
Added Files:
__init__.py configure.zcml globaltranslationservicecontrol.pt
globaltranslationservicecontrol.py runtimeinfo.pt
runtimeinfo.py server-control.pt servercontrol.py
zodbcontrol.pt zodbcontrol.py
Log Message:
Moved browser views and interfaces for applicationcontrol to the
zope.app.applicationcontrol package.
=== Added File Zope3/src/zope/app/applicationcontrol/browser/__init__.py ===
#
# This file is necessary to make this directory a package.
=== Added File Zope3/src/zope/app/applicationcontrol/browser/configure.zcml ===
<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
<pages
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
permission="zope.ManageApplication"
class=
"zope.app.applicationcontrol.browser.servercontrol.ServerControlView">
<page name="ServerControlForm.html" template="server-control.pt"
menu="zmi_views" title="Server Control" />
<page name="ServerControl.html" attribute="action" />
</pages>
<page
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
name="index.html"
menu="zmi_views"
title="Runtime Information"
template="runtimeinfo.pt"
class="zope.app.applicationcontrol.browser.runtimeinfo.RuntimeInfoView"
permission="zope.ManageApplication"/>
<page
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
name="ZODBControl.html"
template="zodbcontrol.pt"
class="zope.app.applicationcontrol.browser.zodbcontrol.ZODBControlView"
permission="zope.ManageApplication"
menu="zmi_views" title="ZODB Control"/>
<page
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
name="GlobalTSControl.html"
template="globaltranslationservicecontrol.pt"
class="zope.app.applicationcontrol.browser.globaltranslationservicecontrol.GlobalTSControlView"
permission="zope.ManageApplication"
menu="zmi_views" title="Global Translation Service Control"/>
<!-- add a action tab to the root folder for navigation -->
<menuItem
menu="zmi_actions"
for="zope.app.interfaces.traversing.IContainmentRoot"
title="Manage Process"
action="++etc++process/index.html" />
</zope:configure>
=== Added File Zope3/src/zope/app/applicationcontrol/browser/globaltranslationservicecontrol.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title i18n:translate="">ZGlobal Transaction Service Controller</title>
</head>
<body>
<div metal:fill-slot="body">
<p tal:define="status view/reloadCatalogs"
tal:condition="status"
tal:content="status" />
<table>
<tr>
<th i18n:translate="">Domain</th>
<th i18n:translate="">Language</th>
<th i18n:translate="">Files</th>
<th> </th>
</tr>
<tr tal:repeat="catalogInfo view/getCatalogsInfo">
<td tal:content="catalogInfo/domain"></td>
<td tal:content="catalogInfo/language"></td>
<td>
<div tal:repeat="fileName catalogInfo/fileNames" tal:content="fileName"></div>
</td>
<td>
<a tal:attributes="href string:?RELOAD=&domain=${catalogInfo/domain}&language=${catalogInfo/language}"
i18n:translate="reload-button">Reload</a>
</td>
</tr>
</table>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/applicationcontrol/browser/globaltranslationservicecontrol.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: globaltranslationservicecontrol.py,v 1.1 2004/03/01 13:43:25 philikon Exp $
"""
from zope.app.applicationcontrol.interfaces import IGlobalTSControl
from zope.component import getAdapter
from zope.app.i18n import ZopeMessageIDFactory as _
class GlobalTSControlView:
def getCatalogsInfo(self):
globaltscontrol = getAdapter(self.context, IGlobalTSControl)
catalogsInfo = globaltscontrol.getCatalogsInfo()
languages_domains = catalogsInfo.keys()
domains_languages = []
for language, domain in languages_domains:
domains_languages.append((domain, language))
domains_languages.sort()
catalogsInfoMaps = []
for domain, language in domains_languages:
fileNames = list(catalogsInfo[(language, domain)])
catalogsInfoMaps.append({'language':language, 'domain':domain,
'fileNames':fileNames})
return catalogsInfoMaps
def reloadCatalogs(self):
"""Do the reloading !"""
status = ''
if 'RELOAD' in self.request:
language = self.request.get('language')
domain = self.request.get('domain')
globaltscontrol = getAdapter(self.context, IGlobalTSControl)
catalogs = globaltscontrol.getCatalogsInfo()
catalogNames = catalogs[(language,domain)]
globaltscontrol.reloadCatalogs(catalogNames)
status = _('message catalog successfully reloaded.')
return status
=== Added File Zope3/src/zope/app/applicationcontrol/browser/runtimeinfo.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title i18n:translate="">Zope Runtime Information</title>
</head>
<body>
<div metal:fill-slot="body">
<ul tal:define="runtime_info view/runtimeInfo">
<li>
<span i18n:translate="">Zope version</span>:
<span tal:replace="runtime_info/ZopeVersion" />
</li>
<li>
<span i18n:translate="">Python version</span>:
<span tal:replace="runtime_info/PythonVersion" />
</li>
<li>
<span i18n:translate="">System platform</span>:
<span tal:replace="runtime_info/SystemPlatform" />
</li>
<li>
<span i18n:translate="">Command line</span>:
<span tal:replace="runtime_info/CommandLine" />
</li>
<li>
<span i18n:translate="">Process id</span>:
<span tal:replace="runtime_info/ProcessId" />
</li>
<li>
<span i18n:translate="">Uptime</span>:
<span tal:replace="runtime_info/Uptime" />
</li>
<li>
<span i18n:translate="">Python path</span>:
<ul>
<li tal:repeat="path runtime_info/PythonPath"
tal:content="path">path</li>
</ul>
</li>
<!-- # XXX UI folks: following line wants special attention. The
hardcoding should be removed someday. -->
<li tal:condition="runtime_info/Hint | nothing" style="color:red;"
tal:content="runtime_info/Hint" i18n:translate="" />
</ul>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/applicationcontrol/browser/runtimeinfo.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: runtimeinfo.py,v 1.1 2004/03/01 13:43:25 philikon Exp $
"""
from zope.app.applicationcontrol.interfaces import IRuntimeInfo
from zope.component import getAdapter
from zope.component import ComponentLookupError
from zope.app.i18n import ZopeMessageIDFactory as _
class RuntimeInfoView:
def runtimeInfo(self):
formatted = {} # will contain formatted runtime information
try:
runtime_info = getAdapter(self.context, IRuntimeInfo)
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
uptime = _('${days} day(s) ${hours}:${minutes}:${seconds}')
uptime.mapping = {'days': '%d' %days,
'hours': '%02d' %hours,
'minutes': '%02d' %minutes,
'seconds': '%02d' %seconds}
formatted['Uptime'] = uptime
except ComponentLookupError:
# We avoid having errors in the ApplicationController,
# because all those things need to stay accessible.
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['Uptime'] = "N/A"
formatted['Hint'] = "Could not retrieve runtime information."
return formatted
=== Added File Zope3/src/zope/app/applicationcontrol/browser/server-control.pt ===
<html metal:use-macro="views/standard_macros/page" i18n:domain="zope">
<head>
<title i18n:translate="">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"
i18n:attributes="value" /> <br />
<input type="submit" name="shutdown" value="Shutdown server"
i18n:attributes="value" /> <br />
</form>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/applicationcontrol/browser/servercontrol.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: servercontrol.py,v 1.1 2004/03/01 13:43:25 philikon Exp $
"""
from zope.app.applicationcontrol.interfaces import IServerControl
from zope.component import getUtility
from zope.app.i18n import ZopeMessageIDFactory as _
class ServerControlView:
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 _(u"You restarted the server."))
elif 'shutdown' in self.request:
return (self.serverControl().shutdown()
or _("You shut down the server."))
=== Added File Zope3/src/zope/app/applicationcontrol/browser/zodbcontrol.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title i18n:translate="">ZODB Controller</title>
</head>
<body>
<div metal:fill-slot="body">
<div style="font-size: 120%" i18n:translate="">
Size of file: <em tal:content="view/getDatabaseSize"
i18n:name="size">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" i18n:translate="">Keep up to:</div>
<div class="view">
<input type="text" size="4" name="days" value="0" /><span tal:omit-tag="" i18n:translate="">days</span>
</div>
</div>
<div class="row">
<div class="control">
<input type="submit" name="PACK" value="Pack"
i18n:attributes="value pack-button"/>
</div>
</div>
</form>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/applicationcontrol/browser/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 2004/03/01 13:43:25 philikon Exp $
"""
from ZODB.FileStorage.FileStorage import FileStorageError
from zope.app.applicationcontrol.interfaces import IZODBControl
from zope.component import getAdapter
from zope.app.i18n import ZopeMessageIDFactory as _
class ZODBControlView:
def getDatabaseSize(self):
"""Get the database size in a human readable format."""
zodbcontrol = getAdapter(self.context, IZODBControl)
size = zodbcontrol.getDatabaseSize(self.request.publication.db)
if size > 1024**2:
size_str = _("${size} MB")
size_str.mapping = {'size': "%.1f" %(float(size)/1024**2)}
elif size > 1024:
size_str = _("${size} kB")
size_str.mapping = {'size': "%.1f" %(float(size)/1024)}
else:
size_str = _("${size} Bytes")
size_str.mapping = {'size': "%i" %size}
return size_str
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
More information about the Zope3-Checkins
mailing list