當前位置: 首頁>>代碼示例>>Python>>正文


Python Group.name方法代碼示例

本文整理匯總了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
開發者ID:nischalhp,項目名稱:linkur,代碼行數:30,代碼來源:userDAO.py

示例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
開發者ID:nischalhp,項目名稱:linkur,代碼行數:52,代碼來源:app.py

示例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
開發者ID:nischalhp,項目名稱:linkur,代碼行數:18,代碼來源:groupDAO.py

示例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)
開發者ID:KatrinkaYu,項目名稱:Task1,代碼行數:18,代碼來源:test_change_group.py

示例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
開發者ID:nischalhp,項目名稱:linkur,代碼行數:20,代碼來源:groupDAO.py


注:本文中的model.group.Group.name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。