【发布时间】:2013-02-24 02:47:08
【问题描述】:
我正在尝试使用烧瓶-mongokit 连接创建索引:
db = MongoKit(app)
db.mydatabase.users.create_index("email", unique=True)
但它向我抛出了这个错误:
...
host=ctx.app.config.get('MONGODB_HOST'),
AttributeError: 'NoneType' object has no attribute 'app'
如果我直接使用 Pymongo:
conn = MongoClient()
conn.mydatabase.users.create_index("email", unique=True)
一切正常!
问题是我不想管理 pymongo 的连接,而是使用由 mongokit 扩展创建的连接。
【问题讨论】:
-
ctx是在哪里定义的? -
我没有定义 ctx,因为 pymongo 无需我定义就可以工作
标签: python indexing flask pymongo mongokit