def delete(request):
    id = request.matchdict["id"]
    json_str = bucket.get(id)[2]
    beer_dict = json.loads(json_str)
    beer = Beer()    
    for key in beer_dict:
        beer.__dict__[key] = beer_dict[key]
    beer.id = id
    return { "model" : beer }
def details(request):
    id = request.matchdict["id"]    
    rows = bucket.view("_design/breweries/_view/all_with_beers", stale=False, startkey=json.dumps([id, 0]), endkey=json.dumps([id, u"\uefff", 1]))
    
    json_str = bucket.get(id)[2]
    brewery_dict = json.loads(json_str)
    brewery = Brewery()
    for key in brewery_dict:
        brewery.__dict__[key] = brewery_dict[key]
        
    for row in rows[1:len(rows)]:
        try:
            json_str = bucket.get(row["id"])[2]
            beer_dict = json.loads(json_str)
            beer = Beer()    
            for key in beer_dict:
                beer.__dict__[key] = beer_dict[key]
            beer.id = id
            brewery.beers.append(beer)
        except Exception, e:
            pass