I am trying to pass the results of differents aggregates in an array. But have a cursor error which I cannot figure out. when aggregations are replaced by string values, it works. Could anyone figure out where I am doing it wrong? any help would be appreciated. here the codes.
---------This is the error-----------------------------------------
- <pymongo.command_cursor.CommandCursor object at 0x0000000002B122B0>
- <pymongo.command_cursor.CommandCursor object at 0x0000000002B492B0>
--------analytics.py-------------------------------------
#ALL AGGREGATES
@bottle.route('/all/')
def home_page():
# connect to mongoDB
connection = pymongo.MongoClient('localhost', 27017)
# attach to test database
db = connection.customers
# get handle for names collection
complaints = db.complaints
# find a single document
aggr1 = db.complaints.aggregate([{"$group":{"_id":"$disputed", "Total_Disputed":{"$sum":1}}},{"$sort":{"Total_Disputed":-1}},{"$project":{"_id":0, "disputed":"$_id", "Total_Disputed":1}}])
aggr2 = db.complaints.aggregate([{"$group":{"_id":"$product", "Total_Product":{"$sum":1}}},{"$sort":{"Total_Product":-1}},{"$project":{"_id":0, "product":"$_id", "Total_Product":1}}])
aggr = [aggr1,aggr2]
return bottle.template('analytics', {'username':"Dispute Aggregate Analytics", 'things':aggr})
bottle.debug(True)
bottle.run(host='localhost', port=8082)
----------------analytics.tpl----------------------------------------------------------------------------------------
<!DOCTYPE hml>
<html>
<head>
<title> @2015 </title>
</head>
<body>
<p>
{{username}}
</p>
<p>
<ul>
%for thing in things:
<li>{{thing}}</li>
%end
</ul></p>
</body>
</html>