[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ApplicationControl - ApplicationControl.py:1.2 IApplicationControl.py:1.2 IRuntimeInfo.py:1.2 IZopeVersion.py:1.2 RuntimeInfo.py:1.2 ZopeVersion.py:1.2 __init__.py:1.2 application-control-meta.zcml:1.2 application-control.zcml:1.2 metaConfigure.py:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:28:22 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ApplicationControl
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/ApplicationControl

Added Files:
	ApplicationControl.py IApplicationControl.py IRuntimeInfo.py 
	IZopeVersion.py RuntimeInfo.py ZopeVersion.py __init__.py 
	application-control-meta.zcml application-control.zcml 
	metaConfigure.py 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/ApplicationControl.py 1.1 => 1.2 ===
+#
+# 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__ = """ Application Control
+
+$Id$"""
+
+from IApplicationControl import IApplicationControl
+
+import time
+
+class ApplicationControl:
+    """ """
+
+    __implements__ = IApplicationControl
+
+    def __init__(self):
+        self.start_time = time.time()
+        self._views = []
+
+    ############################################################
+    # Implementation methods for interface
+    # Zope.App.OFS.ApplicationControl.IApplicationControl.
+
+    def getStartTime(self):
+        'See Zope.App.OFS.ApplicationControl.IApplicationControl.IApplicationControl'
+        return self.start_time
+
+    def registerView(self, name, title):
+        'See Zope.App.OFS.ApplicationControl.IApplicationControl.IApplicationControl'
+        self._views.append({'name': name, 'title': title})
+
+    def getListOfViews(self):
+        'See Zope.App.OFS.ApplicationControl.IApplicationControl.IApplicationControl'
+        return tuple(self._views)
+
+    #
+    ############################################################
+
+ApplicationController = ApplicationControl()
+


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/IApplicationControl.py 1.1 => 1.2 ===
+#
+# 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__ = """ Application Control Interface
+
+$Id$"""
+
+from Interface import Interface
+
+class IApplicationControl(Interface):
+    """ """
+
+    def getStartTime():
+        """Return the time when the ApplicationControl object has been instanciated
+           in seconds since the epoch"""
+
+    def registerView(name, title):
+        """Register a view called <name> to be displayed in ApplicationControl
+        """
+
+    def getListOfViews():
+        """Return a sequence containing dictionaries with the registered views' names
+        and titles mapped with the keys 'name' and 'title'"""


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/IRuntimeInfo.py 1.1 => 1.2 ===
+#
+# 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__ = """ Runtime Information Interface
+
+$Id$"""
+
+from Interface import Interface
+
+class IRuntimeInfo(Interface):
+    """ Runtime Information Adapter for Application Control """
+
+    def getZopeVersion():
+        """Return a string containing the descriptive version of the
+           current zope installation"""
+
+    def getPythonVersion():
+        """Return a string containing verbose description of the python
+           interpreter"""
+    
+    def getPythonPath():
+        """Return a tuple containing the lookup paths of the python interpreter
+        """
+
+    def getSystemPlatform():
+        """Return the system platform name in a 5 tuple of
+           (sysname, nodename, release, version, machine)"""
+
+    def getCommandLine():
+        """Return the command line string Zope was invoked with"""
+
+    def getProcessId():
+        """Return the process id number currently serving the request
+        """
+
+    def getUptime():
+        """Return a string containing the Zope server uptime in unix uptime
+           format with seconds ([NN days, ]HH:MM:SS)"""
+


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/IZopeVersion.py 1.1 => 1.2 ===
+#
+# 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__ = """Zope version interface
+
+$Id$"""
+
+from Interface import Interface
+
+class IZopeVersion(Interface):
+    """ Zope version """
+
+    def getZopeVersion():
+        """Return a string containing the Zope version (possibly including
+           CVS information)"""
+


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/RuntimeInfo.py 1.1 => 1.2 ===
+#
+# 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__ = """ Runtime Information
+
+$Id$"""
+
+from Zope.App.OFS.ApplicationControl.IRuntimeInfo import IRuntimeInfo
+from Zope.App.OFS.ApplicationControl.IApplicationControl import IApplicationControl
+from Zope.ComponentArchitecture import getUtility, ComponentLookupError
+from IZopeVersion import IZopeVersion
+import sys, os, time
+
+class RuntimeInfo:
+
+    __implements__ =  IRuntimeInfo
+    __used_for__ = IApplicationControl
+    
+    def __init__(self, context):
+        self.context = context
+    
+    ############################################################
+    # Implementation methods for interface
+    # Zope.App.OFS.ApplicationControl.IRuntimeInfo.
+
+    def getZopeVersion(self):
+        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
+        try:
+            version_utility = getUtility(self.context, IZopeVersion)
+        except ComponentLookupError:
+            return ""
+        return version_utility.getZopeVersion()
+
+    def getPythonVersion(self):
+        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
+        return sys.version
+
+    def getPythonPath(self):
+        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
+        return tuple(sys.path)
+
+    def getSystemPlatform(self):
+        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
+        if hasattr(os, "uname"):
+            return os.uname()
+        else:
+            return (sys.platform,)
+
+    def getCommandLine(self):
+        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
+        return sys.argv
+
+    def getProcessId(self):
+        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
+        return os.getpid()
+    
+    def getUptime(self):
+        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
+        return time.time() - self.context.getStartTime()
+
+    #
+    ############################################################


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/ZopeVersion.py 1.1 => 1.2 ===
+#
+# 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__ = """Zope version
+
+$Id$"""
+
+from Zope.App.OFS.ApplicationControl.IZopeVersion import IZopeVersion
+import os
+
+class ZopeVersion:
+
+    __implements__ =  IZopeVersion
+
+    ############################################################
+    # Implementation methods for interface
+    # Zope.App.OFS.ApplicationControl.IZopeVersion.
+
+    def getZopeVersion(self):
+        'See Zope.App.OFS.ApplicationControl.IZopeVersion.IZopeVersion'
+
+        version_id = "Development/Unknown"
+        version_tag = ""
+        is_cvs = 0
+        
+        import Zope
+        zopedir = os.path.dirname(Zope.__file__)
+        
+        # is this a CVS checkout?
+        cvsdir = os.path.join(zopedir, "CVS" )
+        if os.path.isdir(cvsdir):
+            is_cvs = 1
+            tagfile = os.path.join(cvsdir, "Tag")
+            
+            # get the tag information
+            if os.path.isfile(tagfile):
+                f = open(tagfile)
+                tag = f.read()
+                if tag.startswith("T"):
+                    version_tag = " (%s)" % tag[1:-1]
+        
+        # try to get official Zope release information
+        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 = "%s%s" % (version_id, version_tag)
+        return version
+
+
+    #
+    ############################################################
+
+ZopeVersionUtility = ZopeVersion()    


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/__init__.py 1.1 => 1.2 ===


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/application-control-meta.zcml 1.1 => 1.2 ===
+
+  <!-- Zope.App.OFS.ApplicationControl -->
+  <directives namespace="http://namespaces.zope.org/application-control">
+    <directive name="registerView"
+               attributes="name title"
+               handler=".metaConfigure.registerView" />
+  </directives>
+
+  <include package=".ServerControl" file="server-control-meta.zcml" />
+</zopeConfigure>


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/application-control.zcml 1.1 => 1.2 ===
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:security='http://namespaces.zope.org/security'
+   xmlns:zmi='http://namespaces.zope.org/zmi'
+   xmlns:browser='http://namespaces.zope.org/browser'
+   xmlns:xmlrpc='http://namespaces.zope.org/xmlrpc'
+>
+
+  <content class=".ApplicationControl.">
+    <security:require
+        permission="Zope.ManageApplication"
+        interface=".IApplicationControl." />
+  </content>
+
+  <adapter factory=".RuntimeInfo."
+           permission="Zope.ManageApplication"
+           provides=".IRuntimeInfo."
+           for=".IApplicationControl." />
+
+  <utility component=".ZopeVersion.ZopeVersionUtility"
+           provides=".IZopeVersion." />
+
+  <include package=".Views" file="views.zcml" />   
+  <include package=".ServerControl" file="server-control.zcml" />
+
+</zopeConfigure>


=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/metaConfigure.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+""" Register Application Control configuration directives.
+
+$Id$
+"""
+
+from ApplicationControl import ApplicationController
+from Zope.Configuration.Action import Action
+
+
+def registerView(_context, name, title):
+    return [
+        Action(
+            discriminator = ('application-control:registerView', name),
+            callable = ApplicationController.registerView,
+            args = (name, title),
+            )
+        ]
+