In my controller method, I'd like to know whether I'm returning JSON or HTML to determine whether to redirect or just return a status code. So I have something like:

@expose( template="foo", allow_json=True )
def method( self ):
if format_is_json:
return dict( status: "OK" )
else:
turbogears.redirect( next_url )

Given that there are several ways to specify that output should be JSON format (Accept header and tg_format parameter at least), how can I be certain whether the caller is looking for JSON?

On an unrelated note: the new Generic function nastiness that's been stuffed into the expose decorator makes things considerably more difficult to understand. I'm certain it makes someone feel warm and fuzzy knowing TG is using generic functions, but I took one look at it and decided I didn't want to know how it worked.

Of course, some comments might help.

--
Jeff Watkins

"Advertising directed at children is inherently deceptive and exploits children under eight years of age."
-- American Academy of Pediatrics



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears Trunk" 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-trunk
-~----------~----~----~----~------~----~------~--~---

Reply via email to