[Zope3-checkins] CVS: Zope3/src/zope/app/applicationcontrol - zodbcontrol.py:1.1 applicationcontrol.py:1.5 configure.zcml:1.3 meta.zcml:1.3 metaconfigure.py:1.3 runtimeinfo.py:1.4 servercontrol.py:1.7 zopeversion.py:1.5

Stephan Richter srichter@cosmos.phy.tufts.edu
Thu, 31 Jul 2003 17:37:55 -0400


Update of /cvs-repository/Zope3/src/zope/app/applicationcontrol
In directory cvs.zope.org:/tmp/cvs-serv12920/applicationcontrol

Modified Files:
	applicationcontrol.py configure.zcml meta.zcml 
	metaconfigure.py runtimeinfo.py servercontrol.py 
	zopeversion.py 
Added Files:
	zodbcontrol.py 
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/applicationcontrol/zodbcontrol.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""ZODB Control

$Id: zodbcontrol.py,v 1.1 2003/07/31 21:37:18 srichter Exp $
"""
import os
from zope.interface import implements
from zope.app.interfaces.applicationcontrol import \
     IApplicationControl, IZODBControl

class ZODBControl:

    implements(IZODBControl)
    __used_for__ = IApplicationControl

    def __init__(self, context):
        self.context = context

    def getDatabaseSize(self, db):
        """See zope.app.interfaces.applicationControl.IZODBControl"""
        return os.path.getsize(db._storage._file_name)

    def pack(self, db, days):
        """See zope.app.interfaces.applicationControl.IZODBControl"""
        db.pack(days=days)


=== Zope3/src/zope/app/applicationcontrol/applicationcontrol.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/applicationcontrol/applicationcontrol.py:1.4	Sat Jun  7 02:37:18 2003
+++ Zope3/src/zope/app/applicationcontrol/applicationcontrol.py	Thu Jul 31 17:37:18 2003
@@ -15,8 +15,7 @@
 
 $Id$"""
 
-from zope.app.interfaces.applicationcontrol.applicationcontrol \
-     import IApplicationControl
+from zope.app.interfaces.applicationcontrol import IApplicationControl
 from zope.app.content.folder import RootFolder
 from zope.security.checker import ProxyFactory, NamesChecker
 from zope.interface import implements


=== Zope3/src/zope/app/applicationcontrol/configure.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/applicationcontrol/configure.zcml:1.2	Wed Dec 25 09:12:25 2002
+++ Zope3/src/zope/app/applicationcontrol/configure.zcml	Thu Jul 31 17:37:18 2003
@@ -1,25 +1,34 @@
-<zopeConfigure xmlns="http://namespaces.zope.org/zope"
-               xmlns:server-control="http://namespaces.zope.org/server-control"
-               >
+<zopeConfigure 
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:server-control="http://namespaces.zope.org/server-control">
 
   <content
-     class="zope.app.applicationcontrol.applicationcontrol.ApplicationControl">
+      class="zope.app.applicationcontrol.applicationcontrol.ApplicationControl">
     <require
         permission="zope.ManageApplication"
-        interface="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl" />
+        interface="zope.app.interfaces.applicationcontrol.IApplicationControl"/>
   </content>
 
-  <adapter factory="zope.app.applicationcontrol.runtimeinfo.RuntimeInfo"
-           permission="zope.ManageApplication"
-           provides="zope.app.interfaces.applicationcontrol.runtimeinfo.IRuntimeInfo"
-           for="zope.app.interfaces.applicationcontrol.applicationcontrol.IApplicationControl" />
+  <adapter 
+      for="zope.app.interfaces.applicationcontrol.IApplicationControl"
+      provides="zope.app.interfaces.applicationcontrol.IRuntimeInfo"
+      factory="zope.app.applicationcontrol.runtimeinfo.RuntimeInfo"
+      permission="zope.ManageApplication" />
 
-  <utility component="zope.app.applicationcontrol.zopeversion.ZopeVersionUtility"
-           provides="zope.app.interfaces.applicationcontrol.zopeversion.IZopeVersion" />
+  <adapter 
+      for="zope.app.interfaces.applicationcontrol.IApplicationControl"
+      provides="zope.app.interfaces.applicationcontrol.IZODBControl"
+      factory="zope.app.applicationcontrol.zodbcontrol.ZODBControl"
+      permission="zope.ManageApplication" />
 
-  <utility factory="zope.app.applicationcontrol.servercontrol.ServerControl"
-           permission="zope.ManageApplication"
-           provides="zope.app.interfaces.applicationcontrol.servercontrol.IServerControl" />
+  <utility 
+      component="zope.app.applicationcontrol.zopeversion.ZopeVersionUtility"
+      provides="zope.app.interfaces.applicationcontrol.IZopeVersion" />
+
+  <utility 
+      provides="zope.app.interfaces.applicationcontrol.IServerControl"
+      factory="zope.app.applicationcontrol.servercontrol.ServerControl"
+      permission="zope.ManageApplication"/>
 
   <!-- Hint: Here you see how to register something on Zope shutdown -->
   <server-control:registerShutdownHook


=== Zope3/src/zope/app/applicationcontrol/meta.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/applicationcontrol/meta.zcml:1.2	Wed Dec 25 09:12:25 2002
+++ Zope3/src/zope/app/applicationcontrol/meta.zcml	Thu Jul 31 17:37:18 2003
@@ -1,10 +1,10 @@
 <zopeConfigure xmlns='http://namespaces.zope.org/zope'>
 
   <directives namespace="http://namespaces.zope.org/server-control">
-    <directive name="registerShutdownHook"
-               attributes="call priority name"
-               handler="
-                zope.app.applicationcontrol.metaconfigure.registerShutdownHook"
+    <directive 
+        name="registerShutdownHook"
+        attributes="call priority name"
+        handler="zope.app.applicationcontrol.metaconfigure.registerShutdownHook"
     />
   </directives>
 


=== Zope3/src/zope/app/applicationcontrol/metaconfigure.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/applicationcontrol/metaconfigure.py:1.2	Wed Dec 25 09:12:25 2002
+++ Zope3/src/zope/app/applicationcontrol/metaconfigure.py	Thu Jul 31 17:37:18 2003
@@ -17,7 +17,7 @@
 """
 
 from zope.component import getUtility
-from zope.app.interfaces.applicationcontrol.servercontrol import IServerControl
+from zope.app.interfaces.applicationcontrol import IServerControl
 from zope.configuration.action import Action
 
 


=== Zope3/src/zope/app/applicationcontrol/runtimeinfo.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/applicationcontrol/runtimeinfo.py:1.3	Sat Jun  7 02:37:18 2003
+++ Zope3/src/zope/app/applicationcontrol/runtimeinfo.py	Thu Jul 31 17:37:18 2003
@@ -11,17 +11,16 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-__doc__ = """ Runtime Information
+""" Runtime Information
 
-$Id$"""
+$Id$
+"""
+import sys, os, time
 
-from zope.app.interfaces.applicationcontrol.runtimeinfo import IRuntimeInfo
-from zope.app.interfaces.applicationcontrol.applicationcontrol \
-    import IApplicationControl
+from zope.app.interfaces.applicationcontrol import \
+     IRuntimeInfo, IApplicationControl, IZopeVersion
 from zope.component import getUtility, ComponentLookupError
-from zope.app.interfaces.applicationcontrol.zopeversion import IZopeVersion
 from zope.interface import implements
-import sys, os, time
 
 class RuntimeInfo:
 
@@ -32,6 +31,7 @@
         self.context = context
 
     def getZopeVersion(self):
+        """See zope.app.interfaces.applicationcontrol.IRuntimeInfo"""
         try:
             version_utility = getUtility(self.context, IZopeVersion)
         except ComponentLookupError:
@@ -39,25 +39,29 @@
         return version_utility.getZopeVersion()
 
     def getPythonVersion(self):
+        """See zope.app.interfaces.applicationcontrol.IRuntimeInfo"""
         return sys.version
 
     def getPythonPath(self):
+        """See zope.app.interfaces.applicationcontrol.IRuntimeInfo"""
         return tuple(map(str, sys.path))
 
     def getSystemPlatform(self):
+        """See zope.app.interfaces.applicationcontrol.IRuntimeInfo"""
         if hasattr(os, "uname"):
             return os.uname()
         else:
             return (sys.platform,)
 
     def getCommandLine(self):
+        """See zope.app.interfaces.applicationcontrol.IRuntimeInfo"""
         return sys.argv
 
     def getProcessId(self):
+        """See zope.app.interfaces.applicationcontrol.IRuntimeInfo"""
         return os.getpid()
 
     def getUptime(self):
+        """See zope.app.interfaces.applicationcontrol.IRuntimeInfo"""
         return time.time() - self.context.getStartTime()
 
-    #
-    ############################################################


=== Zope3/src/zope/app/applicationcontrol/servercontrol.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/applicationcontrol/servercontrol.py:1.6	Mon Jun 30 14:28:24 2003
+++ Zope3/src/zope/app/applicationcontrol/servercontrol.py	Thu Jul 31 17:37:18 2003
@@ -15,10 +15,9 @@
 
 $Id$
 """
-
 import logging
 
-from zope.app.interfaces.applicationcontrol.servercontrol import \
+from zope.app.interfaces.applicationcontrol import \
      IServerControl, DoublePriorityError, NotCallableError
 from zope.interface import implements
 
@@ -34,6 +33,7 @@
         self._shutdown_reg = {}
 
     def shutdown(self):
+        """See zope.app.interfaces.applicationcontrol.IServerControl"""
         order = self._shutdown_reg.keys()
         order.sort()
 
@@ -42,9 +42,11 @@
             hook[0]()
 
     def restart(self):
+        """See zope.app.interfaces.applicationcontrol.IServerControl"""
         pass
 
     def registerShutdownHook(self, call, priority, name):
+        """See zope.app.interfaces.applicationcontrol.IServerControl"""
         priority = float(priority)
         if priority in self._shutdown_reg:
             raise DoublePriorityError, (call, priority, name)
@@ -53,10 +55,6 @@
             raise NotCallableError, (call, priority, name)
 
         self._shutdown_reg.update({priority: (call, name)})
-
-
-    #
-    ############################################################
 
 
 


=== Zope3/src/zope/app/applicationcontrol/zopeversion.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/applicationcontrol/zopeversion.py:1.4	Sat Jun  7 02:37:18 2003
+++ Zope3/src/zope/app/applicationcontrol/zopeversion.py	Thu Jul 31 17:37:18 2003
@@ -18,7 +18,7 @@
 import os
 
 import zope
-from zope.app.interfaces.applicationcontrol.zopeversion import IZopeVersion
+from zope.app.interfaces.applicationcontrol import IZopeVersion
 from zope.interface import implements
 
 class ZopeVersion:
@@ -26,6 +26,7 @@
     implements(IZopeVersion)
 
     def getZopeVersion(self):
+        """See zope.app.interfaces.applicationcontrol.IZopeVersion"""
 
         version_id = "Development/Unknown"
         version_tag = ""
@@ -50,7 +51,7 @@
         versionfile = os.path.join(zopedir, "version.txt")
         if os.path.isfile(versionfile) and not is_cvs:
             f = open(versionfile)
-            version_id = f.read().split("\n")[0] or version_id
+            version_id = f.readlines()[0] or version_id
 
         version = "%s%s" % (version_id, version_tag)
         return version