Problem posting JSON request to index of mounted tree. Cherrypy assumes GET when it's a POST and drops JSON data

mbs <[email protected]> Fri, 10 Feb 2017 03:05:01 -0800 (PST)
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
Hi,

I'm currently have all my cherrypy pages in the huge class
(called RootServer()) and am now trying to split this class
by moving pages into their own classes.
Pages in the class are called with JSON inport via POST requests.

My problem:

I after splitting, I need to call the page with a slash at the end,
which breaks existing uses by third parties.

For the following example I need to call
    http://localhost/status/
to get a result while
  http://localhost/status
gives me
    AttributeError: 'Request' object has no attribute 'json'
(more details at the end of this post)

The pages are mounted this way:

  cp.tree.mount(RootServer(), '', {})
  cp.tree.mount(StatusServer(), '/status', {})

The StatusServer() class looks like this

  class StatusServer:
      # status message
      @cp.expose()
      @cp.tools.json_in(
          content_type=[u'application/json', u'text/javascript', 
u'text/html'],
          force=False)
      @cp.tools.json_out()
      def index(self):
          """Status message"""
          return my_internal_processor_function.status(cp.request.json)

Some more info:

- I use SoapUI to send the POST request.

- When I debug the "index" status function, on "status/" requests, the 
self.json directory is filled and self.method is "POST"

- On "status" requests with no slash, the self.json directory is missing 
and self.method is "GET"

- To verify that I always send "POST" requests: When I move "status" back 
in the main RootServer() class and
mount just that, "status" requests work and self.method is "POST"

- I'm using the current cherrypy version 10.1.0 on windows 7 32bit

I must have my configuration for the second tree wrong somehow.
Any hints?

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.