[Checkins] SVN: zope.app.applicationcontrol/trunk/ Use zope.applicationcontrol.

Martijn Faassen faassen at startifact.com
Sat Jan 9 09:58:16 EST 2010


Log message for revision 107936:
  Use zope.applicationcontrol.
  

Changed:
  U   zope.app.applicationcontrol/trunk/CHANGES.txt
  U   zope.app.applicationcontrol/trunk/buildout.cfg
  U   zope.app.applicationcontrol/trunk/setup.py
  U   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/applicationcontrol.py
  U   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/configure.zcml
  U   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/interfaces.py
  U   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/runtimeinfo.py
  D   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_applicationcontrol.py
  D   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py
  U   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_zopeversion.py
  U   zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/zopeversion.py
  D   zope.app.applicationcontrol/trunk/test.py

-=-
Modified: zope.app.applicationcontrol/trunk/CHANGES.txt
===================================================================
--- zope.app.applicationcontrol/trunk/CHANGES.txt	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/CHANGES.txt	2010-01-09 14:58:15 UTC (rev 107936)
@@ -5,9 +5,10 @@
 3.5.5 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Extracted RuntimeInfo and ApplicationRoot functionality into
+  zope.applicationcontrol. Import this functionality from this package
+  instead (see BBB imports inside this package).
 
-
 3.5.4 (2010-01-08)
 ------------------
 

Modified: zope.app.applicationcontrol/trunk/buildout.cfg
===================================================================
--- zope.app.applicationcontrol/trunk/buildout.cfg	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/buildout.cfg	2010-01-09 14:58:15 UTC (rev 107936)
@@ -1,7 +1,6 @@
 [buildout]
-develop = . 
+develop = .
 parts = test
-find-links = http://download.zope.org/distribution/
 
 [test]
 recipe = zc.recipe.testrunner

Modified: zope.app.applicationcontrol/trunk/setup.py
===================================================================
--- zope.app.applicationcontrol/trunk/setup.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/setup.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -66,6 +66,7 @@
     namespace_packages=['zope', 'zope.app'],
     install_requires=[
           'setuptools',
+          'zope.applicationcontrol',
           'zope.component',
           'zope.i18nmessageid',
           'zope.interface',

Modified: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/applicationcontrol.py
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/applicationcontrol.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/applicationcontrol.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -16,32 +16,8 @@
 $Id$"""
 __docformat__ = 'restructuredtext'
 
-import time
-import zope.interface
-import zope.traversing.interfaces
-from zope.location import Location
-from zope.security.checker import ProxyFactory, NamesChecker
-from zope.app.applicationcontrol.interfaces import IApplicationControl
-
-class ApplicationControl(Location):
-
-    zope.interface.implements(IApplicationControl)
-
-    def __init__(self):
-        self.start_time = time.time()
-
-    def getStartTime(self):
-        return self.start_time
-
-
-applicationControllerRoot = Location()
-zope.interface.directlyProvides(
+# BBB
+from zope.applicationcontrol.applicationcontrol import (
+    ApplicationControl,
     applicationControllerRoot,
-    zope.traversing.interfaces.IContainmentRoot,
-    )
-applicationControllerRoot = ProxyFactory(applicationControllerRoot,
-                                         NamesChecker("__class__"))
-
-applicationController = ApplicationControl()
-applicationController.__parent__ = applicationControllerRoot
-applicationController.__name__ = '++etc++process'
+    applicationController)

Modified: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/configure.zcml
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/configure.zcml	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/configure.zcml	2010-01-09 14:58:15 UTC (rev 107936)
@@ -3,41 +3,12 @@
    i18n_domain="zope"
    >
 
-  <permission
-     id="zope.ManageApplication"
-     title="[manage-application-permission] Manage Application"
-     description="Manage the Zope Application, such as Restart/Shutdown or
-                  packing the ZODB."
-     />
+  <include package="zope.applicationcontrol" />
 
-  <class class=".applicationcontrol.ApplicationControl">
-    <require
-       permission="zope.ManageApplication"
-       interface=".interfaces.IApplicationControl"/>
-  </class>
-  
-  <adapter 
-     for=".interfaces.IApplicationControl"
-     provides=".interfaces.IRuntimeInfo"
-     factory=".runtimeinfo.RuntimeInfo"
-     permission="zope.ManageApplication" />
-  
   <utility 
      component=".zopeversion.ZopeVersionUtility"
      provides=".interfaces.IZopeVersion" />
 
-  <utility
-     component=".applicationcontrol.applicationController"
-     provides="zope.traversing.interfaces.IEtcNamespace"
-     name="process"
-     />
-
-  <utility
-     component=".applicationcontrol.applicationController"
-     provides="zope.traversing.interfaces.IEtcNamespace"
-     name="ApplicationController"
-     />
-
   <!-- Include browser package -->
 
   <include package=".browser" />

Modified: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/interfaces.py
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/interfaces.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/interfaces.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -18,91 +18,9 @@
 __docformat__ = 'restructuredtext'
 
 from zope.interface import Interface
-
-class IApplicationControl(Interface):
-    """The application control instance is usually generated upon startup and
-    can therefore record the startup time."""
-
-    def getStartTime():
-        """Return time the application started in seconds since the epoch."""
-
-
-class IRuntimeInfo(Interface):
-    """Runtime Information Adapter for Application Control"""
-
-    def getDeveloperMode():
-        """Return the current developer mode setting"""
-
-    def getPreferredEncoding():
-        """Return the encoding used for text data, according
-           to user system preferences"""
-
-    def getFileSystemEncoding():
-        """Return the name of the encoding used to convert
-           Unicode filenames into system file names"""
-
-    def getZopeVersion():
-        """Return a string containing the descriptive version of the
-           current zope installation"""
-
-    def getPythonVersion():
-        """Return an unicode string containing verbose description
-           of the python interpreter"""
-
-    def getPythonPath():
-        """Return a tuple containing an unicode strings containing
-           the lookup paths of the python interpreter"""
-
-    def getSystemPlatform():
-        """Return an unicode string containing the system platform name
-        """
-
-    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 the Zope server uptime in seconds"""
-
-
-class IZopeVersion(Interface):
-    """ Zope version """
-
-    def getZopeVersion():
-        """Return a string containing the Zope version (possibly including
-           SVN information)"""
-
-
-class IServerControl(Interface):
-    """Defines methods for shutting down and restarting the server.
-
-    This utility also keeps a registry of things to call when shutting down
-    zope. You can register using this interface or the zcml on the global
-    ServerController instance.
-    """
-
-    def shutdown(time=0):
-        """Shutdown the server.
-
-        The `time` should be greater-equal 0.
-
-        If the `time` is 0, then we do a hard shutdown, i.e. closing
-        all sockets without waiting for tasks to complete.
-
-        If the `time` is not 0, then we will give the tasks `time` seconds to
-        finish before shutting down.
-        """
-
-    def restart(time=0):
-        """Restart the server.
-
-        The `time` should be greater-equal 0.
-
-        If the `time` is 0, then we do a hard shutdown, i.e. closing
-        all sockets without waiting for tasks to complete.
-
-        If the `time` is not 0, then we will give the tasks `time` seconds to
-        finish before shutting down.
-        """
+# BBB
+from zope.applicationcontrol.interfaces import (
+    IApplicationControl,
+    IRuntimeInfo,
+    IZopeVersion,
+    IServerControl)

Modified: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/runtimeinfo.py
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/runtimeinfo.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/runtimeinfo.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -17,106 +17,7 @@
 """
 __docformat__ = 'restructuredtext'
 
-import sys
-import os
-import time
+# BBB
+from zope.applicationcontrol.runtimeinfo import (
+    RuntimeInfo)
 
-try:
-    import locale
-except ImportError:
-    locale = None
-
-import platform
-
-from zope.component import getUtility, ComponentLookupError
-from zope.interface import implements
-
-from zope.app.applicationcontrol.i18n import ZopeMessageFactory as _
-
-from zope.app.applicationcontrol.interfaces import IRuntimeInfo
-from zope.app.applicationcontrol.interfaces import IApplicationControl
-from zope.app.applicationcontrol.interfaces import IZopeVersion
-
-try:
-    from zope.app.appsetup import appsetup
-except ImportError:
-    appsetup = None
-
-
-class RuntimeInfo(object):
-    """Runtime information."""
-
-    implements(IRuntimeInfo)
-    __used_for__ = IApplicationControl
-
-    def __init__(self, context):
-        self.context = context
-
-    def getDeveloperMode(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        if appsetup is None:
-            return 'undefined'
-
-        cc=appsetup.getConfigContext()
-        if cc == None:  # make the test run
-            return 'undefined'
-        if cc.hasFeature('devmode'):
-            return 'On'
-        return 'Off'
-
-    def getPreferredEncoding(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        if locale is not None:
-            try:
-                return locale.getpreferredencoding()
-            except locale.Error:
-                pass
-        return sys.getdefaultencoding()
-
-    def getFileSystemEncoding(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        enc = sys.getfilesystemencoding()
-        if enc is None:
-            enc = self.getPreferredEncoding()
-        return enc
-
-    def getZopeVersion(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        try:
-            version_utility = getUtility(IZopeVersion)
-        except ComponentLookupError:
-            return _("Unavailable")
-        return version_utility.getZopeVersion()
-
-    def getPythonVersion(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        return unicode(sys.version, self.getPreferredEncoding())
-
-    def getPythonPath(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        enc = self.getFileSystemEncoding()
-        return tuple([unicode(path, enc) for path in sys.path])
-
-    def getSystemPlatform(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        info = []
-        enc = self.getPreferredEncoding()
-        for item in platform.uname():
-            try:
-                t = unicode(item, enc)
-            except ValueError:
-                continue
-            info.append(t)
-        return u" ".join(info)
-
-    def getCommandLine(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        return unicode(" ".join(sys.argv), self.getPreferredEncoding())
-
-    def getProcessId(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        return os.getpid()
-
-    def getUptime(self):
-        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        return time.time() - self.context.getStartTime()

Deleted: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_applicationcontrol.py
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_applicationcontrol.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_applicationcontrol.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -1,48 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-##############################################################################
-"""Application Control Tests
-
-$Id$
-"""
-import unittest
-from zope.interface.verify import verifyObject
-
-import time
-from zope.app.applicationcontrol.applicationcontrol import ApplicationControl
-from zope.app.applicationcontrol.interfaces import IApplicationControl
-
-# seconds, time values may differ in order to be assumed equal
-time_tolerance = 2
-
-class Test(unittest.TestCase):
-
-    def _Test__new(self):
-        return ApplicationControl()
-
-    def test_IVerify(self):
-        verifyObject(IApplicationControl, self._Test__new())
-
-    def test_startTime(self):
-        assert_time = time.time()
-        test_time = self._Test__new().getStartTime()
-
-        self.failUnless(abs(assert_time - test_time) < time_tolerance)
-
-
-def test_suite():
-    return unittest.TestSuite((
-        unittest.makeSuite(Test),
-        ))
-
-if __name__ == '__main__':
-    unittest.main()

Deleted: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -1,125 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-##############################################################################
-"""Runtime Info Tests
-
-$Id$
-"""
-import unittest
-import os, sys, time
-
-try:
-    import locale
-except ImportError:
-    locale = None
-
-import zope.component
-from zope.interface import implements
-from zope.interface.verify import verifyObject
-from zope.app.applicationcontrol.applicationcontrol import applicationController
-from zope.app.applicationcontrol.interfaces import IRuntimeInfo, IZopeVersion
-from zope.app.component.testing import PlacefulSetup
-
-# seconds, time values may differ in order to be assumed equal
-time_tolerance = 2
-stupid_version_string = "3085t0klvn93850voids"
-
-class TestZopeVersion(object):
-    """A fallback implementation for the ZopeVersion utility."""
-
-    implements(IZopeVersion)
-
-    def getZopeVersion(self):
-        return stupid_version_string
-
-class Test(PlacefulSetup, unittest.TestCase):
-
-    def _Test__new(self):
-        from zope.app.applicationcontrol.runtimeinfo import RuntimeInfo
-        return RuntimeInfo(applicationController)
-
-    def _getPreferredEncoding(self):
-        if locale is not None:
-            try:
-                return locale.getpreferredencoding()
-            except locale.Error:
-                pass
-        return sys.getdefaultencoding()
-
-    def _getFileSystemEncoding(self):
-        enc = sys.getfilesystemencoding()
-        if enc is None:
-            enc = self._getPreferredEncoding()
-        return enc
-
-    def testIRuntimeInfoVerify(self):
-        verifyObject(IRuntimeInfo, self._Test__new())
-
-    def test_PreferredEncoding(self):
-        runtime_info = self._Test__new()
-        enc = self._getPreferredEncoding()
-        self.assertEqual(runtime_info.getPreferredEncoding(), enc)
-
-    def test_FileSystemEncoding(self):
-        runtime_info = self._Test__new()
-        enc = self._getFileSystemEncoding()
-        self.assertEqual(runtime_info.getFileSystemEncoding(), enc)
-
-    def test_ZopeVersion(self):
-        runtime_info = self._Test__new()
-
-        # we expect that there is no utility
-        self.assertEqual(runtime_info.getZopeVersion(), u"Unavailable")
-
-        siteManager = zope.component.getSiteManager()
-        siteManager.registerUtility(TestZopeVersion(), IZopeVersion)
-
-        self.assertEqual(runtime_info.getZopeVersion(), stupid_version_string)
-
-    def test_PythonVersion(self):
-        runtime_info = self._Test__new()
-        enc = self._getPreferredEncoding()
-        self.assertEqual(runtime_info.getPythonVersion(),
-                unicode(sys.version, enc))
-
-    def test_SystemPlatform(self):
-        runtime_info = self._Test__new()
-        self.failUnless(runtime_info.getSystemPlatform())
-
-    def test_CommandLine(self):
-        runtime_info = self._Test__new()
-        self.assertEqual(runtime_info.getCommandLine(), " ".join(sys.argv))
-
-    def test_ProcessId(self):
-        runtime_info = self._Test__new()
-        self.assertEqual(runtime_info.getProcessId(), os.getpid())
-
-    def test_Uptime(self):
-        runtime_info = self._Test__new()
-        # whats the uptime we expect?
-
-        start_time = applicationController.getStartTime()
-        asserted_uptime = time.time() - start_time
-
-        # get the uptime the current implementation calculates
-        test_uptime = runtime_info.getUptime()
-
-        self.failUnless(abs(asserted_uptime - test_uptime) < time_tolerance)
-
-
-def test_suite():
-    return unittest.TestSuite((
-        unittest.makeSuite(Test),
-        ))
-
-if __name__ == '__main__':
-    unittest.main()

Modified: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_zopeversion.py
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_zopeversion.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/tests/test_zopeversion.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -22,7 +22,7 @@
 import unittest
 
 from zope.interface.verify import verifyObject
-from zope.app.applicationcontrol.interfaces import IZopeVersion
+from zope.applicationcontrol.interfaces import IZopeVersion
 from zope.app.applicationcontrol.zopeversion import ZopeVersion
 
 

Modified: zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/zopeversion.py
===================================================================
--- zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/zopeversion.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/src/zope/app/applicationcontrol/zopeversion.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -22,7 +22,7 @@
 import subprocess
 
 import zope.app
-from zope.app.applicationcontrol.interfaces import IZopeVersion
+from zope.applicationcontrol.interfaces import IZopeVersion
 from zope.interface import implements
 
 

Deleted: zope.app.applicationcontrol/trunk/test.py
===================================================================
--- zope.app.applicationcontrol/trunk/test.py	2010-01-09 14:54:30 UTC (rev 107935)
+++ zope.app.applicationcontrol/trunk/test.py	2010-01-09 14:58:15 UTC (rev 107936)
@@ -1,40 +0,0 @@
-#!/usr/bin/env python
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""Sample test script using zope.testing.testrunner
-
-see zope.testing testrunner.txt
-
-$Id: test.py 70876 2006-10-22 07:42:56Z baijum $
-"""
-
-import os, sys
-
-here = os.path.abspath(os.path.dirname(sys.argv[0]))
-
-# Remove this directory from path:
-sys.path[:] = [p for p in sys.path if os.path.abspath(p) != here]
-
-src = os.path.join(here, 'src')
-sys.path.insert(0, src) # put at beginning to avoid one in site_packages
-
-from zope.testing import testrunner
-
-defaults = [
-    '--path', src,
-    '--package', 'zope.app.applicationcontrol',
-    '--tests-pattern', '^f?tests$',
-    ]
-
-sys.exit(testrunner.run(defaults))



More information about the checkins mailing list