changeset 4582:afc6264a134f

raised requirement to Python 2.4, removing 2.3 support code
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 15 Feb 2009 03:21:00 +0100
parents 70a0acbf0bb3
children 124c1919133d
files MoinMoin/log.py MoinMoin/script/old/migration/12_to_13_mig01.py MoinMoin/script/old/migration/12_to_13_mig06.py MoinMoin/script/old/migration/12_to_13_mig10.py MoinMoin/script/old/xmlrpc-tools/UpdateGroupTest.py MoinMoin/script/xmlrpc/write.py MoinMoin/support/multicall.py MoinMoin/support/python_compatibility.py MoinMoin/wikisync.py jabberbot/multicall.py jabberbot/xmlrpcbot.py wikiserver.py
diffstat 12 files changed, 24 insertions(+), 216 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/log.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/log.py	Sun Feb 15 03:21:00 2009 +0100
@@ -154,15 +154,3 @@
             setattr(logger, levelname, levelnumber)
     return logger
 
-
-# Python 2.3's logging module has no .log, this provides it:
-if not hasattr(logging, 'log'):
-    def log(level, msg, *args, **kwargs):
-        if len(logging.root.handlers) == 0:
-            logging.basicConfig()
-        if logging.root.manager.disable >= level:
-            return
-        if level >= logging.root.getEffectiveLevel():
-            logging.root._log(level, msg, args, **kwargs)
-    logging.log = log
-
--- a/MoinMoin/script/old/migration/12_to_13_mig01.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/script/old/migration/12_to_13_mig01.py	Sun Feb 15 03:21:00 2009 +0100
@@ -18,7 +18,7 @@
             c. if you used symlinks in data/text or elsewhere, remove them
         4. make sure that from_encoding and to_encoding matches your needs (see
            beginning of script below and config.charset in moin_config.py) and
-           run python2.3 12_to_13_mig1.py from your working dir
+           run python 12_to_13_mig1.py from your working dir
         5. if there was no error, you will find:
             data.pre-mig1 (the script renames your data directory copy to that name)
             data (result, converted to utf-8)
--- a/MoinMoin/script/old/migration/12_to_13_mig06.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/script/old/migration/12_to_13_mig06.py	Sun Feb 15 03:21:00 2009 +0100
@@ -16,7 +16,7 @@
             c. if you used symlinks in data/text or elsewhere, remove them
         4. make sure that from_encoding and to_encoding matches your needs (see
            beginning of script below and config.charset in moin_config.py) and
-           run python2.3 12_to_13_mig6.py from your working dir
+           run python 12_to_13_mig6.py from your working dir
         5. if there was no error, you will find:
             data.pre-mig6 (the script renames your data directory copy to that name)
             data (result, converted to utf-8)
--- a/MoinMoin/script/old/migration/12_to_13_mig10.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/script/old/migration/12_to_13_mig10.py	Sun Feb 15 03:21:00 2009 +0100
@@ -13,7 +13,7 @@
 
         3. make sure that from_encoding and to_encoding matches your needs (see
            beginning of script below and config.charset in moin_config.py) and
-           run python2.3 12_to_13_mig10.py from your working dir
+           run python 12_to_13_mig10.py from your working dir
 
         4. If there was no error, you will find:
             data.pre-mig10 - the script renames your data directory copy to that name
--- a/MoinMoin/script/old/xmlrpc-tools/UpdateGroupTest.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/script/old/xmlrpc-tools/UpdateGroupTest.py	Sun Feb 15 03:21:00 2009 +0100
@@ -16,9 +16,6 @@
 
 import xmlrpclib
 
-# we have a fixed xmlrpc multicall implementation (in py 2.3 it was broken):
-from MoinMoin.support.multicall import MultiCall
-
 
 def updateGroup(server_url, username, password, groupname, groupdesc, groupmembers, acl=''):
     """
@@ -45,7 +42,7 @@
 
     try:
         # build a multicall object that
-        mcall = MultiCall(wiki)
+        mcall = xmlrpclib.MultiCall(wiki)
         # first applies the token and
         mcall.applyAuthToken(auth_token)
         # then creates/updates the group page
--- a/MoinMoin/script/xmlrpc/write.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/script/xmlrpc/write.py	Sun Feb 15 03:21:00 2009 +0100
@@ -10,7 +10,7 @@
 import sys
 
 from MoinMoin.script import MoinScript
-from MoinMoin.support.multicall import MultiCall
+
 
 class PluginScript(MoinScript):
     """\
@@ -65,7 +65,7 @@
             content = sys.stdin.read()
 
             # build a multicall object that
-            mcall = MultiCall(s)
+            mcall = xmlrpclib.MultiCall(s)
             # first applies the token and
             mcall.applyAuthToken(token)
             # then edits the page
--- a/MoinMoin/support/multicall.py	Sun Feb 15 02:23:10 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-""" XMLRPC MultiCall support for Python 2.3. Copied from xmlrpclib.py of Python 2.4.3. """
-
-try:
-    from xmlrpclib import MultiCall
-except ImportError: 
-    from xmlrpclib import Fault
-    
-    class _MultiCallMethod:
-        # some lesser magic to store calls made to a MultiCall object
-        # for batch execution
-        def __init__(self, call_list, name):
-            self.__call_list = call_list
-            self.__name = name
-        def __getattr__(self, name):
-            return _MultiCallMethod(self.__call_list, "%s.%s" % (self.__name, name))
-        def __call__(self, *args):
-            self.__call_list.append((self.__name, args))
-    
-    class MultiCallIterator:
-        """Iterates over the results of a multicall. Exceptions are
-        thrown in response to xmlrpc faults."""
-    
-        def __init__(self, results):
-            self.results = results
-    
-        def __getitem__(self, i):
-            item = self.results[i]
-            if type(item) == type({}):
-                raise Fault(item['faultCode'], item['faultString'])
-            elif type(item) == type([]):
-                return item[0]
-            else:
-                raise ValueError,\
-                      "unexpected type in multicall result"
-    
-    class MultiCall:
-        """server -> a object used to boxcar method calls
-    
-        server should be a ServerProxy object.
-    
-        Methods can be added to the MultiCall using normal
-        method call syntax e.g.:
-    
-        multicall = MultiCall(server_proxy)
-        multicall.add(2,3)
-        multicall.get_address("Guido")
-    
-        To execute the multicall, call the MultiCall object e.g.:
-    
-        add_result, address = multicall()
-        """
-    
-        def __init__(self, server):
-            self.__server = server
-            self.__call_list = []
-    
-        def __repr__(self):
-            return "<MultiCall at %x>" % id(self)
-    
-        __str__ = __repr__
-    
-        def __getattr__(self, name):
-            return _MultiCallMethod(self.__call_list, name)
-    
-        def __call__(self):
-            marshalled_list = []
-            for name, args in self.__call_list:
-                marshalled_list.append({'methodName' : name, 'params' : args})
-    
-            return MultiCallIterator(self.__server.system.multicall(marshalled_list))
--- a/MoinMoin/support/python_compatibility.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/support/python_compatibility.py	Sun Feb 15 03:21:00 2009 +0100
@@ -4,65 +4,32 @@
     Stuff for compatibility with older Python versions
 
     @copyright: 2007 Heinrich Wendel <heinrich.wendel@gmail.com>,
-                2007 MoinMoin:ThomasWaldmann
+                2009 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
-"""
-This is a feature from python 2.4, needed for compatibility with python 2.3,
-although it may not be 100% compatible.
-"""
+min_req_exc = Exception("Minimum requirement for MoinMoin is Python 2.4.")
+
 try:
     import string
-    rsplit = string.rsplit
+    rsplit = string.rsplit # Python >= 2.4 needed
 except AttributeError:
-    # CAUTION: you can't use s.rsplit(...), only rsplit(s, ...) with this!
-    def rsplit(s, sep=None, maxsplit=-1):
-        """rsplit(s [,sep [,maxsplit]]) -> list of strings
-
-        Return a list of the words in the string s, using sep as the
-        delimiter string, starting at the end of the string and working
-        to the front.  If maxsplit is given, at most maxsplit splits are
-        done. If sep is not specified or is None, any whitespace string
-        is a separator.
-        """
-        fragments = s[::-1].split(sep, maxsplit)
-        return [fragment[::-1] for fragment in fragments[::-1]]
+    raise min_req_exc
 
-"""
-This is a feature from python 2.4, needed for compatibility with python 2.3,
-although it may not be 100% compatible.
-"""
 try:
-    sorted = sorted
+    sorted = sorted # Python >= 2.4 needed
 except NameError:
-    def sorted(l, *args, **kw):
-        if type(l) == dict:
-            l = l.keys()
-        l = l[:]
-        # py2.3 is a bit different
-        if 'cmp' in kw:
-            args = (kw['cmp'], )
+    raise min_req_exc
 
-        l.sort(*args)
-        return l
-
-"""
-This is a feature from python 2.4, needed for compatibility with python 2.3,
-although it may not be 100% compatible.
-"""
 try:
-    set = set
+    set = set # Python >= 2.4 needed
     frozenset = frozenset
 except NameError:
-    from sets import Set as set
-    from sets import ImmutableSet as frozenset
+    raise min_req_exc
 
-"""
-This is a feature from python 2.5, needed for compatibility with python 2.3 and 2.4.
-"""
+
 try:
-    from functools import partial
+    from functools import partial # Python >= 2.5 needed
 except (NameError, ImportError):
     class partial(object):
         def __init__(*args, **kw):
@@ -76,12 +43,10 @@
             else:
                 d = kw or self.kw
             return self.fn(*(self.args + args), **d)
-"""
-This is a feature from python 2.5, needed for compatibility with python 2.3 and 2.4,
-although it may not be 100% compatible.
-"""
+
+
 try:
-    import hashlib, hmac
+    import hashlib, hmac # Python >= 2.5 needed
     hash_new = hashlib.new
     def hmac_new(key, msg, digestmod=hashlib.sha1):
         return hmac.new(key, msg, digestmod)
--- a/MoinMoin/wikisync.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/MoinMoin/wikisync.py	Sun Feb 15 03:21:00 2009 +0100
@@ -15,7 +15,6 @@
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.packages import unpackLine, packLine
-from MoinMoin.support.multicall import MultiCall
 
 
 MIMETYPE_MOIN = "text/wiki"
@@ -249,7 +248,7 @@
 
     def create_multicall_object(self):
         """ Generates an object that can be used like a MultiCall instance. """
-        return MultiCall(self.connection)
+        return xmlrpclib.MultiCall(self.connection)
 
     def prepare_multicall(self):
         """ Can be used to return initial calls that e.g. authenticate the user.
@@ -281,7 +280,7 @@
                    "pagelist": self.pagelist,
                    "mark_deleted": True}
         if self.token:
-            m = MultiCall(self.connection)
+            m = xmlrpclib.MultiCall(self.connection)
             m.applyAuthToken(self.token)
             m.getAllPagesEx(options)
             tokres, pages = m()
--- a/jabberbot/multicall.py	Sun Feb 15 02:23:10 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-""" XMLRPC MultiCall support for Python 2.3. Copied from xmlrpclib.py of Python 2.4.3. """
-
-try:
-    from xmlrpclib import MultiCall
-except ImportError:
-    from xmlrpclib import Fault
-
-    class _MultiCallMethod:
-        # some lesser magic to store calls made to a MultiCall object
-        # for batch execution
-        def __init__(self, call_list, name):
-            self.__call_list = call_list
-            self.__name = name
-        def __getattr__(self, name):
-            return _MultiCallMethod(self.__call_list, "%s.%s" % (self.__name, name))
-        def __call__(self, *args):
-            self.__call_list.append((self.__name, args))
-
-    class MultiCallIterator:
-        """Iterates over the results of a multicall. Exceptions are
-        thrown in response to xmlrpc faults."""
-
-        def __init__(self, results):
-            self.results = results
-
-        def __getitem__(self, i):
-            item = self.results[i]
-            if type(item) == type({}):
-                raise Fault(item['faultCode'], item['faultString'])
-            elif type(item) == type([]):
-                return item[0]
-            else:
-                raise ValueError,\
-                      "unexpected type in multicall result"
-
-    class MultiCall:
-        """server -> a object used to boxcar method calls
-
-        server should be a ServerProxy object.
-
-        Methods can be added to the MultiCall using normal
-        method call syntax e.g.:
-
-        multicall = MultiCall(server_proxy)
-        multicall.add(2,3)
-        multicall.get_address("Guido")
-
-        To execute the multicall, call the MultiCall object e.g.:
-
-        add_result, address = multicall()
-        """
-
-        def __init__(self, server):
-            self.__server = server
-            self.__call_list = []
-
-        def __repr__(self):
-            return "<MultiCall at %x>" % id(self)
-
-        __str__ = __repr__
-
-        def __getattr__(self, name):
-            return _MultiCallMethod(self.__call_list, name)
-
-        def __call__(self):
-            marshalled_list = []
-            for name, args in self.__call_list:
-                marshalled_list.append({'methodName': name, 'params': args})
-
-            return MultiCallIterator(self.__server.system.multicall(marshalled_list))
--- a/jabberbot/xmlrpcbot.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/jabberbot/xmlrpcbot.py	Sun Feb 15 03:21:00 2009 +0100
@@ -11,7 +11,6 @@
 from threading import Thread
 
 import jabberbot.commands as cmd
-from jabberbot.multicall import MultiCall
 
 
 class ConfigurationError(Exception):
@@ -33,7 +32,7 @@
         _ = lambda x: x
 
         self.token = None
-        self.multicall = MultiCall(self.connection)
+        self.multicall = xmlrpclib.MultiCall(self.connection)
         jid = command.jid
         if type(jid) is not list:
             jid = [jid]
--- a/wikiserver.py	Sun Feb 15 02:23:10 2009 +0100
+++ b/wikiserver.py	Sun Feb 15 03:21:00 2009 +0100
@@ -14,7 +14,7 @@
 
 # a1) Path of the directory where the MoinMoin code package is located.
 #     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
-#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+#sys.path.insert(0, 'PREFIX/lib/python2.4/site-packages')
 
 # a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
 moinpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))