本文整理汇总了Python中model.group.Group.name方法的典型用法代码示例。如果您正苦于以下问题:Python Group.name方法的具体用法?Python Group.name怎么用?Python Group.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.group.Group
的用法示例。
在下文中一共展示了Group.name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_groups
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import name [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: create_user_groups
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import name [as 别名]
def create_user_groups():
user = validate_cookie(request)
print user.__str__()
responseWrapper = ResponseWrapper()
print "hello new group"
response = any_response(request)
if user != None:
group = Group()
try:
# form_data = request.form['data']
print request.form
form_data = request.form['data']
json_data = json.loads(form_data)
group.name = json_data['group_name']
print "appending to group user ", user.id
group.users.append(user.id)
except Exception as inst:
print inst
print "Error reading form data"
responseWrapper.set_error(True)
responseWrapper.set_data([inst])
response.data = json.dumps(responseWrapper, default=ResponseWrapper.__str__)
response.mimetype = "application/json"
return response
new_group_id = groupDAO.insert_group(group)
group.id = new_group_id
result = userDAO.append_group(user.id,group)
if result != None:
responseWrapper.set_error(False)
new_group_id = str(new_group_id)
responseWrapper.set_data([{"group_id":new_group_id}])
else:
responseWrapper.set_error(True)
responseWrapper.set_data(["error writing group"])
else:
responseWrapper.set_error(True)
responseWrapper.set_data(["User not found. Please login again"])
response.status_code = 302
response.data = json.dumps(responseWrapper, default=ResponseWrapper.__str__)
response.mimetype = "application/json"
return response
示例3: get_group_by_hash
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import name [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
示例4: test_change_some_group_header
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import name [as 别名]
def test_change_some_group_header(app, db, check_ui):
if len(db.get_group_list()) == 0:
app.group.create(Group(name="group", header="new", footer="new_1"))
old_groups = db.get_group_list()
old_group = random.choice(old_groups)
id = old_group.id
group = Group(header="change_new_group")
app.group.change_by_id(id, group)
group.id =id
group.name = old_group.name
new_groups = db.get_group_list()
old_groups.insert(old_groups.index(old_group), group)
old_groups.remove(old_group)
assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
if check_ui:
assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)
示例5: get_group_by_id
# 需要导入模块: from model.group import Group [as 别名]
# 或者: from model.group.Group import name [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