json_in usage example

1,004 views
Skip to first unread message

jbastos

unread,
Jun 14, 2012, 3:03:10 PM6/14/12
to cherryp...@googlegroups.com
I'm trying to use the cherrypy.lib.jsontools.json_in as a decorator. The problem is that I get an exception like:

  File "/Users/jbastos/workspace/env/namoro/lib/python2.7/site-packages/cherrypy/lib/jsontools.py", line 50, in json_in
    request.body.processors.clear()
AttributeError: 'NoneType' object has no attribute 'processors'

What am I doing wrong?


Eric Larson

unread,
Jun 14, 2012, 4:28:08 PM6/14/12
to cherryp...@googlegroups.com
What dispatcher are you using? The tools won't work as decorators with the routes dispatcher, but they've worked for me using the default and method dispatcher.


HTH,

Eric

>
> --
> You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/cherrypy-users/-/9YHu2WiSSvEJ.
> To post to this group, send email to cherryp...@googlegroups.com.
> To unsubscribe from this group, send email to cherrypy-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.

jbastos

unread,
Jun 15, 2012, 12:25:14 AM6/15/12
to cherryp...@googlegroups.com
I''m using the default dispatcher. 



On Thursday, June 14, 2012 5:28:08 PM UTC-3, Eric Larson wrote:
[...]

Eric Larson

unread,
Jun 15, 2012, 12:55:11 PM6/15/12
to cherryp...@googlegroups.com

On Jun 14, 2012, at 11:25 PM, jbastos wrote:

> I''m using the default dispatcher.
>
>


Can you paste an example of how you are using them?

Here is how I've done it:

@cherrypy.tools.json_in()
def foo(self):
json = cherrypy.request.json

Eric

>
> On Thursday, June 14, 2012 5:28:08 PM UTC-3, Eric Larson wrote:
> [...]
>
> What dispatcher are you using? The tools won't work as decorators with the routes dispatcher, but they've worked for me using the default and method dispatcher.
>
>
> HTH,
>
> Eric
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/cherrypy-users/-/tEidp1GNNq4J.

jbastos

unread,
Jun 21, 2012, 10:15:38 PM6/21/12
to cherryp...@googlegroups.com
It worked! Thanks a lot!!!

Jose


On Friday, June 15, 2012 1:55:11 PM UTC-3, Eric Larson wrote:

Can you paste an example of how you are using them?

Here is how I've done it:

  @cherrypy.tools.json_in()
  def foo(self):
      json = cherrypy.request.json

Eric

>
> On Thursday, June 14, 2012 5:28:08 PM UTC-3, Eric Larson wrote:
> [...]
>
> What dispatcher are you using? The tools won't work as decorators with the routes dispatcher, but they've worked for me using the default and method dispatcher.
>
>
> HTH,
>
> Eric
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/cherrypy-users/-/tEidp1GNNq4J.
> To post to this group, send email to cherrypy-users@googlegroups.com.
> To unsubscribe from this group, send email to cherrypy-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages