[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/Views/Browser - ServerControlView.py:1.1.2.1 __init__.py:1.1.2.1 browser.zcml:1.1.2.1 server-control.pt:1.1.2.1
Philipp von Weitershausen
philikon@gmx.net
Wed, 10 Apr 2002 10:41:56 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv2399/ServerControl/Views/Browser
Added Files:
Tag: Zope-3x-branch
ServerControlView.py __init__.py browser.zcml
server-control.pt
Log Message:
Added a plugin for ApplicationControl for shutting down and restarting the
server. There is no implementation available yet, though.
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/Views/Browser/ServerControlView.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.
#
##############################################################################
"""Provides a view for IServerControl
$Id: ServerControlView.py,v 1.1.2.1 2002/04/10 14:41:55 philikon Exp $
"""
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.App.OFS.ApplicationControl.ServerControl.IServerControl import IServerControl
from Zope.ComponentArchitecture import getUtility
class ServerControlView(AttributePublisher):
def __init__(self, context):
self._context = context
def getContext(self):
return self._context
def serverControl(self):
return getUtility(self.getContext(), IServerControl) # XXX what are we going to do if this fails???
def action(self, REQUEST=None):
if REQUEST.has_key('restart'):
self.serverControl().restart()
elif REQUEST.has_key('shutdown'):
self.serverControl().shutdown()
index = PageTemplateFile('server-control.pt')
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/Views/Browser/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/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'
xmlns:application-control='http://namespaces.zope.org/application-control'
>
<!-- ServerControl View Directives -->
<browser:view name="servercontrol"
for="Zope.App.OFS.ApplicationControl.IApplicationControl."
factory=".ServerControlView." />
<application-control:registerView name="servercontrol"
title="Server control" />
<security:protectClass
name=".ServerControlView."
permission_id="Zope.ManageApplication"
methods="index, action" />
</zopeConfigure>
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/Views/Browser/server-control.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title>Zope Stub Server Controller</title>
</head>
<body>
<div metal:fill-slot="body">
<!-- XXX /ApplicationController;etc/servercontrol;view/restart is a workaround for the unavailable
absolute_url function. -->
<form name="servercontrol" tal:attributes="action string:/ApplicationController;;etc/servercontrol;;view/action" method="post">
<input type="submit" name="restart" value="Restart server" /> <br />
<input type="submit" name="shutdown" value="Shutdown server" /> <br />
</form>
</div>
</body>
</html>