【发布时间】:2012-03-10 15:17:36
【问题描述】:
@route('/locations', method='GET')
def get_location():
entity = db['locations'].find({'coordinate2d': {'$near': [37.871593, -122.272747]}}).limit(3)
if not entity:
abort(404, 'No nearby locations')
return entity
上面部分代码的响应是:
Error 500: Internal Server Error
Sorry, the requested URL 'http://localhost:8080/locations' caused an error:
Unsupported response type: <type 'dict'>
我如何从 mongo 中获取该信息作为 Bottle 可以返回为 JSON 的类型?
【问题讨论】:
-
您是否尝试过分解问题,即用简单的字典文字替换
db.find调用?如果它以这种方式工作,那么问题一定是与 Mongo 相关的。是不是,和瓶子有关。 -
@Helgi 我有,Bottle 当然可以使用常规字典文字。但它无法处理 MongoDB ObjectId。