[Checkins] SVN: zope.applicationcontrol/trunk/s Compatibility requires the notion of a zope version to be at least

Martijn Faassen faassen at startifact.com
Sat Jan 9 09:42:28 EST 2010


Log message for revision 107931:
  Compatibility requires the notion of a zope version to be at least
  introduced here, though not implemented.
  

Changed:
  U   zope.applicationcontrol/trunk/setup.py
  D   zope.applicationcontrol/trunk/src/zope/applicationcontrol/i18n.py
  U   zope.applicationcontrol/trunk/src/zope/applicationcontrol/interfaces.py
  U   zope.applicationcontrol/trunk/src/zope/applicationcontrol/runtimeinfo.py
  U   zope.applicationcontrol/trunk/src/zope/applicationcontrol/tests/test_runtimeinfo.py

-=-
Modified: zope.applicationcontrol/trunk/setup.py
===================================================================
--- zope.applicationcontrol/trunk/setup.py	2010-01-09 14:34:26 UTC (rev 107930)
+++ zope.applicationcontrol/trunk/setup.py	2010-01-09 14:42:28 UTC (rev 107931)
@@ -56,8 +56,8 @@
     namespace_packages=['zope'],
     install_requires=[
           'setuptools',
-          'zope.i18nmessageid',
           'zope.interface',
+          'zope.component',
           'zope.location',
           'zope.security',
           'zope.traversing>=3.7.0',

Deleted: zope.applicationcontrol/trunk/src/zope/applicationcontrol/i18n.py
===================================================================
--- zope.applicationcontrol/trunk/src/zope/applicationcontrol/i18n.py	2010-01-09 14:34:26 UTC (rev 107930)
+++ zope.applicationcontrol/trunk/src/zope/applicationcontrol/i18n.py	2010-01-09 14:42:28 UTC (rev 107931)
@@ -1,22 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Customization of zope.i18n for the Zope application server
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-# import this as _ to create i18n messages in the zope domain
-from zope.i18nmessageid import MessageFactory
-ZopeMessageFactory = MessageFactory('zope')

Modified: zope.applicationcontrol/trunk/src/zope/applicationcontrol/interfaces.py
===================================================================
--- zope.applicationcontrol/trunk/src/zope/applicationcontrol/interfaces.py	2010-01-09 14:34:26 UTC (rev 107930)
+++ zope.applicationcontrol/trunk/src/zope/applicationcontrol/interfaces.py	2010-01-09 14:42:28 UTC (rev 107931)
@@ -41,6 +41,15 @@
         """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.
+        
+        Deprecated: the concept of a Zope version went away in the
+        Zope Toolkit. It is unlikely this gives sensible results in
+        many situations.
+        """
+        
     def getPythonVersion():
         """Return an unicode string containing verbose description
            of the python interpreter"""
@@ -62,7 +71,17 @@
     def getUptime():
         """Return the Zope server uptime in seconds"""
 
+class IZopeVersion(Interface):
+    """Zope version
 
+    Note: The notion of a zope version is deprecated to the Zope Toolkit.
+    """
+
+    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.
 

Modified: zope.applicationcontrol/trunk/src/zope/applicationcontrol/runtimeinfo.py
===================================================================
--- zope.applicationcontrol/trunk/src/zope/applicationcontrol/runtimeinfo.py	2010-01-09 14:34:26 UTC (rev 107930)
+++ zope.applicationcontrol/trunk/src/zope/applicationcontrol/runtimeinfo.py	2010-01-09 14:42:28 UTC (rev 107931)
@@ -28,10 +28,12 @@
 
 import platform
 
+from zope.component import getUtility, ComponentLookupError
 from zope.interface import implements
 
 from zope.applicationcontrol.interfaces import IRuntimeInfo
 from zope.applicationcontrol.interfaces import IApplicationControl
+from zope.applicationcontrol.interfaces import IZopeVersion
 
 try:
     from zope.app.appsetup import appsetup
@@ -76,6 +78,14 @@
             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())

Modified: zope.applicationcontrol/trunk/src/zope/applicationcontrol/tests/test_runtimeinfo.py
===================================================================
--- zope.applicationcontrol/trunk/src/zope/applicationcontrol/tests/test_runtimeinfo.py	2010-01-09 14:34:26 UTC (rev 107930)
+++ zope.applicationcontrol/trunk/src/zope/applicationcontrol/tests/test_runtimeinfo.py	2010-01-09 14:42:28 UTC (rev 107931)
@@ -22,14 +22,24 @@
 except ImportError:
     locale = None
 
+from zope import component
+from zope.interface import implements
 from zope.interface.verify import verifyObject
 from zope.applicationcontrol.applicationcontrol import applicationController
-from zope.applicationcontrol.interfaces import IRuntimeInfo
+from zope.applicationcontrol.interfaces import IRuntimeInfo, IZopeVersion
 
 # 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(unittest.TestCase):
 
     def _Test__new(self):
@@ -63,6 +73,17 @@
         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 = 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()



More information about the checkins mailing list