Thanks for the suggestion. That's pretty much the solution I came up with. params.update(json.loads(request.body))
I didn't know about request.json_body though. On Tuesday, July 15, 2014 1:49:00 PM UTC-6, Alessandro Molina wrote: > > Here is a short example that does what you are looking for: > http://runnable.com/U8WDEFXA3A47DT0X/parse-json-data-from-request-in-turbogears-for-python > > > On Tue, Jul 15, 2014 at 6:48 PM, Alessandro Molina <[email protected] > <javascript:>> wrote: > >> Just noticed your problem was related to passing arguments into the >> request body as JSON. >> >> That is something TurboGears RestController won't do out of the box, the >> tgext.crud extension EasyCrudRestController does that using a >> @before_validate(allow_json_parameters) decorator which is implemented >> here: >> https://github.com/TurboGears/tgext.crud/blob/master/tgext/crud/utils.py#L169 >> >> You probably want to do the same so that you can freely pass json encoded >> arguments to TG. >> >> >> On Thu, Jul 3, 2014 at 8:58 AM, Alessandro Molina <[email protected] >> <javascript:>> wrote: >> >>> There is an example on using TG with Angular at >>> http://turbogears.readthedocs.org/en/latest/cookbook/Crud/restapi.html#leveraging-your-rest-api-on-angularjs >>> >>> did you check it that works for you? >>> >>> You might want to compare how $resource and your $http call send that to >>> check for differences. >>> >>> >>> >>> On Thu, Jul 3, 2014 at 1:21 AM, Barry Loper <[email protected] >>> <javascript:>> wrote: >>> >>>> Hi there. I'm having trouble using the RestController with AngularJS. >>>> I've looked through the tutorial on using Angular with >>>> EasyCrudRestController, but if there was a solution to my problem in >>>> there, >>>> I'm not finding it. It could just be my lack of experience that is >>>> stumping >>>> me, but hopefully someone on here can help me. >>>> >>>> The bottom line is that I submit some application/json data with a PUT >>>> or POST, but my **kw in my controller is empty. The data is available in >>>> tg.request.body, but I'm not sure if that can be accessed by an @validate >>>> decorator. >>>> >>>> My Angular request looks like this: >>>> >>>>> $http({ >>>>> >>>>> 'method': 'PUT', >>>>> >>>>> 'url': '../api/entity.json', >>>>> >>>>> 'data': $scope.entity, >>>>> >>>>> 'responseType': 'application/json' >>>>> >>>>> } ) >>>>> >>>>> >>>> My request payload as shown by Chrome looks like json. I've tried >>>> doing angular.fromJson($scope.entity) and even angular.toJson(), but >>>> Turbogears isn't able to populate the **kw dict with the json data. >>>> >>>> In the debug log, I can see the data is coming through by printing out >>>> json.loads(request.body). printing out kw, gets me {}. >>>> >>>> The only workaround so far is to pass the POST/PUT info in 'params'. >>>> I'd rather not. Any ideas? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "TurboGears" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected] <javascript:>. >>>> To post to this group, send email to [email protected] >>>> <javascript:>. >>>> Visit this group at http://groups.google.com/group/turbogears. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >> > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

