本文整理汇总了Python中model.group.Group.hash方法的典型用法代码示例。如果您正苦于以下问题:Python Group.hash方法的具体用法?Python Group.hash怎么用?Python Group.hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.group.Group
的用法示例。
在下文中一共展示了Group.hash方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_groups
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import hash [as 别名]
def get_groups(self, uname):
# get all groups for this user
group = None
user_groups = None
try:
collection = self.user_collection
user_groups = collection.find_one({'_id':uname},{"groups":True})
except Exception as inst:
print "error reading groups"
print inst
if user_groups != None:
group_cursor = user_groups["groups"]
groups = []
for item in group_cursor:
print item
group = Group()
group.id = str(item["_id"])
group.name = item["name"]
group.hash = item["hash"]
groups.append(group)
return groups
else:
return None
示例2: get_group_by_hash
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import hash [as 别名]
def get_group_by_hash(self, invite_hash):
collection = self.collection
result = collection.find_one({"hash": invite_hash});
if result != None:
group = Group()
group.id = result["_id"]
# print group.id
group.name = result["name"]
group.hash = result["hash"]
group.users = result["users"]
return group
else:
return None
示例3: get_group_by_id
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import hash [as 别名]
def get_group_by_id(self, group_id):
# get group document from db
collection = self.collection
group_id = ObjectId(group_id)
result = collection.find_one({"_id": group_id});
if result != None:
group = Group()
group.id = group_id
# print group.id
group.name = result["name"]
group.hash = result["hash"]
group.users = result["users"]
return group
else:
return None