Re: Simple RESTful API - make a patch
Kearney Taaffe <[email protected]> Mon, 14 Nov 2016 05:40:13 -0800 (PST)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
@Josheph
That fixed it!
I changed my def PATHCH method to the following:
@cherrypy.tools.json_in()
@cherrypy.tools.json_out()
def PATCH(self, **kwargs: Dict[str, str]):
# the _cp_dispatch() method
if 'uuid' not in kwargs:
result = {
'success' : False,
'message' : 'You must specfy a user.'
}
return result
else:
print('found uuid: ' + kwargs['uuid'])
# get the request body
data = cherrypy.request.json
print('HTTP BODY: ' + str(data))
# result = self.userService.updateUser(data, kwargs['uuid'])
result = {
'status' : 'patching user ({})'.format(kwargs['uuid'])
}
return result
And, that printed both the body and the route parameter!
So, what do I need to do next? Submit a bug report? Branch, and ask my
branch to be merged into the master branch?
Thanks for all your help! I super appreciate it!
On Thursday, November 10, 2016 at 1:22:13 PM UTC-6, Joseph Tate wrote:
>
> It looks like there's at least one bug in CherryPy. _cprequest.py
> needs to be updated to look like this:
>
> methods_with_bodies = ('POST', 'PUT', 'PATCH')
>
> But then I'm getting an error on the JSON document. I hope this is enough
> to help you get going.
>
> If you have time to submit a pull request with this change (and hopefully
> a test), I'd appreciate it.
>
> On Thu, Nov 10, 2016 at 1:51 PM Joseph S. Tate <[email protected]
> <javascript:>> wrote:
>
>> When I try to reproduce via "telnet localhost 8080", the body line gets
>> pasted to my prompt, so cherrypy is terminating the request before the body
>> is sent. So it's likely a configuration error of some kind.
>>
>> I'm going to pursue that for a bit, but wanted to report that before you
>> go diving into something in the request handler itself.
>>
>>
>> On Thu, Nov 10, 2016 at 11:10 AM Kearney Taaffe
>> <snipped>
>>
>
--
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.