I'm trying to retrieve some summary data via an Ajax request with the following controller method. This is just a simple result set containing a list of tag names and usage counts retrieved in a JOIN query. Here's the code:
def gettagsummary(): ''' Get list of tags and related counts (from tagref table) - user can then view by tag (similar to Stack Overflow tag view??) ''' count = db.tagref.tag.count() tagsummary = db(db.tagref.tag==db.tag.id).select(db.tagref.tag, db.tag.name, count, \ groupby=db.tagref.tag) return dict(tagsummary=tagsummary) >From my webpage I make an Ajax/XHR request to get this info in json format (the request is url: "/search/gettagsummary.json" This is what the request response looks like: {"tagsummary": [ {"tagref": {"tag": 1}, "tag": {"name": "Places"}, "_extra": {"COUNT(tagref.tag)": 4}}, {"tagref": {"tag": 2}, "tag": {"name": "Cars"}, "_extra": {"COUNT(tagref.tag)": 2}}, ' . . . {"tagref": {"tag": 9}, "tag": {"name": "France"}, "_extra": {"COUNT(tagref.tag)": 2}}, {"tagref": {"tag": 10}, "tag": {"name": "UK"}, "_extra": {"COUNT(tagref.tag)": 2}} ]} OK - so far, so good. Now I need to extract the count info in my Ajax response - However the count info is not easily (AFAIK) accessible - the '_extra' structure is a web2py artifact that looks odd. I'm thinking there must be a better way to pass the count info to my view (e.g. {"count":4}. So how do I change this so I can reference the count info. Do I need to change my controller code, or is there some (undocumented) way to reference the '_extra' info in the json response. I can't see anything in the docs on this - so hopefully someone here can point me in the right direction here. TIA, BrendanC