Anonymous committed c03d569

[svn r6078] XmlRpcPlugin: Fix for use of a Trac method only available on 0.11.3 or higher. Made a compat-workaround for now.

Closes #5415.

  • Participants
  • Parent commits de51c7f

Comments (0)

Files changed (2)

File trunk/tracrpc/

 from trac.util.datefmt import utc
 def to_xmlrpc_datetime(dt):
     """ Convert a datetime.datetime object to a xmlrpclib DateTime object """
     return xmlrpclib.DateTime(dt.utctimetuple())
     """Return datetime (in utc) from XMLRPC datetime string (is always utc)"""
     t = list(time.strptime(data.value, "%Y%m%dT%H:%M:%S")[0:6])
     return apply(datetime.datetime, t, {'tzinfo': utc})
+    # Method only available in Trac 0.11.3 or higher
+    from trac.util.text import exception_to_unicode
+except ImportError:
+    def exception_to_unicode(e, traceback=""):
+        from trac.util.text import to_unicode
+        message = '%s: %s' % (e.__class__.__name__, to_unicode(e))
+        if traceback:
+            from trac.util import get_last_traceback
+            traceback_only = get_last_traceback().split('\n')[:-2]
+            message = '\n%s\n%s' % (to_unicode('\n'.join(traceback_only)),
+                                        message)
+        return message

File trunk/tracrpc/

 from trac.core import *
 from trac.perm import PermissionError
 from trac.util.datefmt import utc
-from trac.util.text import to_unicode, exception_to_unicode
+from trac.util.text import to_unicode
 from trac.web.main import IRequestHandler
 from import ITemplateProvider, add_stylesheet
 from import wiki_to_oneliner
 from tracrpc.api import IXMLRPCHandler, XMLRPCSystem
 from tracrpc.util import from_xmlrpc_datetime, to_xmlrpc_datetime
+from tracrpc.util import exception_to_unicode