Commits

Olemis Lang  committed 08279b0

TracRpc: Fixing typo. Now using HTTPInternalError for unhandled exceptions

  • Participants
  • Parent commits a0e7e18

Comments (0)

Files changed (1)

File t5437\t5437-protocol_api_v2-r7194.diff

 
 diff -r a475cf08e780 trunk/tracrpc/api.py
 --- a/trunk/tracrpc/api.py	Sat Mar 13 19:59:29 2010 -0500
-+++ b/trunk/tracrpc/api.py	Sun Mar 14 02:09:01 2010 -0500
++++ b/trunk/tracrpc/api.py	Sun Mar 14 02:27:58 2010 -0500
 @@ -21,13 +21,34 @@
      """ RPC Binary type. Currently == xmlrpclib.Binary. """
      pass
  
 diff -r a475cf08e780 trunk/tracrpc/json_rpc.py
 --- a/trunk/tracrpc/json_rpc.py	Sat Mar 13 19:59:29 2010 -0500
-+++ b/trunk/tracrpc/json_rpc.py	Sun Mar 14 02:09:01 2010 -0500
++++ b/trunk/tracrpc/json_rpc.py	Sun Mar 14 02:27:58 2010 -0500
 @@ -5,8 +5,9 @@
  (c) 2009      ::: www.CodeResort.com - BV Network AS (simon-code@bvnetwork.no)
  """
      def _json_error(self, e, c=None, r_id=None):
 diff -r a475cf08e780 trunk/tracrpc/web_ui.py
 --- a/trunk/tracrpc/web_ui.py	Sat Mar 13 19:59:29 2010 -0500
-+++ b/trunk/tracrpc/web_ui.py	Sun Mar 14 02:09:01 2010 -0500
++++ b/trunk/tracrpc/web_ui.py	Sun Mar 14 02:27:58 2010 -0500
 @@ -6,6 +6,10 @@
  (c) 2009      ::: www.CodeResort.com - BV Network AS (simon-code@bvnetwork.no)
  """
  from pkg_resources import resource_filename
  
  from genshi.builder import tag
-@@ -13,6 +17,8 @@
+@@ -13,15 +17,19 @@
  from genshi.template.text import TextTemplate
  
  from trac.core import *
 +from trac.resource import ResourceNotFound
  from trac.util.text import to_unicode
  from trac.util.translation import _
- from trac.web.api import RequestDone, HTTPUnsupportedMediaType
-@@ -21,7 +27,8 @@
+-from trac.web.api import RequestDone, HTTPUnsupportedMediaType
++from trac.web.api import RequestDone, HTTPUnsupportedMediaType, \
++                          HTTPInternalError
+ from trac.web.main import IRequestHandler
+ from trac.web.chrome import ITemplateProvider, INavigationContributor, \
                              add_stylesheet, add_script, add_ctxtnav
  from trac.wiki.formatter import wiki_to_oneliner
  
  from tracrpc.util import accepts_mimetype
  
  __all__ = ['RPCWeb']
-@@ -59,13 +66,7 @@
+@@ -59,13 +67,7 @@
              # Perform the method call
              self.log.debug("RPC incoming request of content type '%s' " \
                      "dispatched to %s" % (content_type, repr(protocol)))
          elif accepts_mimetype(req, 'text/html'):
              return self._dump_docs(req)
          else:
-@@ -76,6 +77,8 @@
+@@ -76,6 +78,8 @@
              req.send_error(None, template='', content_type='text/plain',
                      status=HTTPUnsupportedMediaType.code, env=None, data=body)
  
      def _dump_docs(self, req):
          # Dump RPC documentation
          req.perm.require('XML_RPC') # Need at least XML_RPC
-@@ -128,6 +131,54 @@
+@@ -128,6 +132,53 @@
              return "Error rendering protocol documentation. " \
                         "Contact your '''Trac''' administrator for details"
  
 +        method_name = rpcreq and rpcreq.get('method') or '(undefined)'
 +        body = "Unhandled protocol error calling '%s'\n\n%s" % (method_name, stackTrace)
 +        req.send_error(None, template='', content_type='text/plain',
-+                            env=None, data=body, 
-+                            status=HTTPUnsupportedMediaType.code)
++                            env=None, data=body, status=HTTPInternalError.code)
 +
      # ITemplateProvider methods
  
      def get_htdocs_dirs(self):
 diff -r a475cf08e780 trunk/tracrpc/xml_rpc.py
 --- a/trunk/tracrpc/xml_rpc.py	Sat Mar 13 19:59:29 2010 -0500
-+++ b/trunk/tracrpc/xml_rpc.py	Sun Mar 14 02:09:01 2010 -0500
++++ b/trunk/tracrpc/xml_rpc.py	Sun Mar 14 02:27:58 2010 -0500
 @@ -19,7 +19,7 @@
  from trac.util.text import to_unicode