Thanks for the reply.

I found my answer. It was at the browser end - TG2 was working properly 
the whole time. I thought I'd checked for this by using two different 
browsers, but apparently neither of them were saving the response 
properly. wget works though.

Sorry for bugging you - nothing quite like that sort of thing to make 
you feel stupid! Been banging my head against that wall for a couple of 
hours now!!

Cheers
Iain


Jorge Vargas wrote:
> On Sun, Dec 14, 2008 at 5:54 PM, Iain <[email protected]> wrote:
>   
>> Hi folks,
>>
>> I'm sure I'm missing something simple, but can't work it out - hoping
>> someone can help me out.
>>
>> I'm trying to use JSON with my TG2 app.
>>
>> I have added the @expose("json") decorator as per the wiki tutorial (I
>> did see that this has not actually been TG2-ified yet). With two
>> decorators on the page, I can't tell it to use the JSON renderer by
>> specifying tg_format=json in the URL - I get an error saying
>> unexpected keyword argument tg_format. I gather from the lists that
>> the use of tg_format is unlikely to continue, or may even be gone
>> already, but I couldn't work out how to ask TG2 to return the page as
>> JSON.
>>
>>     
> yes tg_format is removed in TG2, the (current) correct way is to use
> @expose('json')
>
> by the way this is documented here http://trac.turbogears.org/ticket/1960
>
>   
>> Anyway, so I got rid of the ordinary template @expose decorator,
>> leaving only the @expose("json") and when I visit the URL with my
>> browser I do get a application/json type response, but it is empty. No
>> error messages in the logs or anything either.
>>     
>
> I haven't tried to have two @expose on the same method but I'm pretty
> sure only using @expose('json') works fine, I have been using it in
> the alpha's and betas.
>
> What is your controller returning? it should still return a dict, is
> it returning an object type that isn't list/dict? maybe posting your
> controller will be a good idea.
>
> As a related note, I think that our final implementation for this will
> be to choose the template/render based on the URL, so for example
> project.json will return json while project.html will return html from
> your default html renderer, this new feature is here
> http://trac.turbogears.org/ticket/1473.
>   
>> Any help would be much appreciated.
>>
>> Cheers
>> Iain
>>     
>
> >
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to