本文整理汇总了Python中models.Client.get_collection方法的典型用法代码示例。如果您正苦于以下问题:Python Client.get_collection方法的具体用法?Python Client.get_collection怎么用?Python Client.get_collection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Client
的用法示例。
在下文中一共展示了Client.get_collection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import get_collection [as 别名]
def register(self):
if request.method == u'POST':
client_key = self.generate_client_key()
secret = self.generate_client_secret()
# TODO: input sanitisation?
name = request.form.get(u"name")
description = request.form.get(u"description")
callback = request.form.get(u"callback")
pubkey = request.form.get(u"pubkey")
# TODO: redirect?
# TODO: pubkey upload
# TODO: csrf
info = {
u"client_key": client_key,
u"name": name,
u"description": description,
u"secret": secret,
u"pubkey": pubkey
}
client = Client(**info)
client['callbacks'].append(callback)
client['resource_owner_id'] = g.user['_id']
client_id = Client.insert(client)
g.user.client_ids.append(client_id)
User.get_collection().save(g.user)
return render_template(u"client.html", **info)
else:
clients = Client.get_collection().find({'_id': {'$in':
[ObjectId(oid) for oid in g.user.client_ids]}})
return render_template(u"register.html", clients=clients)