Commits

Olemis Lang committed 42f9cbe

TracRpc: Cosmetic changes. Think we are ready for 1.1.0 ;o)

  • Participants
  • Parent commits 11e2416

Comments (0)

Files changed (1)

t5437/t5437-protocol_api-r7194.diff

 diff --git a/trunk/tracrpc/api.py b/trunk/tracrpc/api.py
 --- a/trunk/tracrpc/api.py
 +++ b/trunk/tracrpc/api.py
-@@ -8,21 +8,28 @@
- 
- from trac.core import *
+@@ -10,19 +10,22 @@
  from trac.perm import IPermissionRequestor
-+import datetime
  import inspect
  import types
 +from datetime import datetime
  import xmlrpclib
 -import datetime
-+
+ 
+-try:
+-    set = set
+-except:
+-    from sets import Set as set
 +__all__ = ['expose_rpc', 'IRPCProtocol', 'IXMLRPCHandler', 'AbstractRPCHandler',
 +            'Method', 'XMLRPCSystem', 'Binary']
- 
- try:
-     set = set
- except:
-     from sets import Set as set
- 
++
++from tracrpc.util import set
++
 +class Binary(xmlrpclib.Binary):
 +    """ RPC Binary type. Currently == xmlrpclib.Binary. """
 +    pass
-+
+ 
  RPC_TYPES = {int: 'int', bool: 'boolean', str: 'string', float: 'double',
 -             xmlrpclib.DateTime: 'dateTime.iso8601', xmlrpclib.Binary: 'base64',
 +             datetime: 'dateTime.iso8601', Binary: 'base64',
  def expose_rpc(permission, return_type, *arg_types):
      """ Decorator for exposing a method as an RPC call with the given
      signature. """
-@@ -35,7 +42,29 @@
+@@ -35,7 +38,29 @@
      return decorator
  
  
      def xmlrpc_namespace():
          """ Provide the namespace in which a set of methods lives.
              This can be overridden if the 'name' element is provided by
-@@ -56,7 +85,6 @@
+@@ -56,7 +81,6 @@
          followed by argument types.
          """
  
  class AbstractRPCHandler(Component):
      implements(IXMLRPCHandler)
      abstract = True
-@@ -180,7 +208,7 @@
+@@ -180,7 +204,7 @@
                  p = Method(provider, *candidate)
                  if p.name == method:
                      return p
          
      # Exported methods
      def all_methods(self, req):
-@@ -199,10 +227,8 @@
+@@ -199,10 +223,8 @@
          for signature in signatures:
              try:
                  yield self.get_method(signature['methodName'])(req, signature['params'])
 diff --git a/trunk/tracrpc/search.py b/trunk/tracrpc/search.py
 --- a/trunk/tracrpc/search.py
 +++ b/trunk/tracrpc/search.py
-@@ -16,6 +16,8 @@
- except:
-     from sets import Set as set
+@@ -7,14 +7,13 @@
+ """
  
+ from trac.core import *
+-from tracrpc.api import IXMLRPCHandler
+ from trac.search.api import ISearchSource
+ from trac.search.web_ui import SearchModule
+ 
+-try:
+-    a = set()
+-except:
+-    from sets import Set as set
++from tracrpc.api import IXMLRPCHandler
++from tracrpc.util import set
++
 +__all__ = ['SearchRPC']
-+
+ 
  class SearchRPC(Component):
      """ Search Trac. """
-     implements(IXMLRPCHandler)
 diff --git a/trunk/tracrpc/templates/rpc.html b/trunk/tracrpc/templates/rpc.html
 new file mode 100644
 --- /dev/null
  
  try:
      # Method only available in Trac 0.11.3 or higher
-@@ -44,3 +30,13 @@
+@@ -44,3 +30,21 @@
      from trac.util.text import empty
  except ImportError:
      empty = None
 +def prepare_docs(text, indent=4):
 +    r"""Remove leading whitespace"""
 +    return ''.join(l[indent:] for l in text.splitlines(True))
++
++try:
++    # Should work with Py >= 2.4
++    set = set
++except:
++    # Should work with Py >= 2.3
++    from sets import Set as set
++
 diff --git a/trunk/tracrpc/web_ui.py b/trunk/tracrpc/web_ui.py
 --- a/trunk/tracrpc/web_ui.py
 +++ b/trunk/tracrpc/web_ui.py