本文整理汇总了Python中models.Group.put方法的典型用法代码示例。如果您正苦于以下问题:Python Group.put方法的具体用法?Python Group.put怎么用?Python Group.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Group
的用法示例。
在下文中一共展示了Group.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: insert
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import put [as 别名]
def insert(self, group_name):
existing_group = self._get_group(group_name=group_name)
if existing_group:
return existing_group
group = Group()
group.user = self.user_key
group.name = group_name
group.put()
return group
示例2: save
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import put [as 别名]
def save(request):
password = post_param(request, 'password')
name = post_param(request, 'name')
members = post_param(request, 'members').split()
group_id = post_param(request, 'group_id')
owner_email = post_param(request, 'owner')
group = None
if group_id:
try:
group = get_group(long(group_id))
require = check_user(group)
if require:
return redirect("/redirect/?%s" % require)
except:
return redirect('/group/edit/?errs=group_id')
for member in get_users(group):
if member.name not in members:
return redirect('/group/edit/%s?errs=members' % group.key().id())
members = save_users(members, group)
owner = None
try:
owner = users.User(owner_email)
except:
owner = users.get_current_user()
if group:
group.members = members
group.owner = owner
else:
group = Group(members = members,
password = password,
name = name,
owner = owner)
while len(group.summaries) < len(members):
group.summaries.append(0.0)
group.put()
return redirect('/redirect/group/')
示例3: post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import put [as 别名]
def post(self):
name = self.request.get('name')
description = self.request.get('description')
privateDescription = self.request.get('private_description')
# Check if group name already exists
existingGroups = Group.query(Group.name==name).fetch()
if len(existingGroups) > 0:
self.display_message('A group with this name already exists')
return
newGroup = Group(name=name, description=description, privateDescription=privateDescription)
newGroup.put()
newGroupMembership = GroupMembership()
newGroupMembership.groupKey = newGroup.key
newGroupMembership.userKey = self.user.key
newGroupMembership.isAdministrator = True
newGroupMembership.isModerator = True
newGroupMembership.put()
self.redirect(self.uri_for('home'))
示例4: groups_post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import put [as 别名]
def groups_post(request):
name = request.REQUEST['name']
parentId = request.REQUEST['id']
type = request.REQUEST['type'] if ('type' in request.REQUEST) else 'group'
# XXX errors
#parentGroupQuery = Group.gql('WHERE __key__ = :1', parentId)
if (parentId == None or parentId.__len__() == 0):
key = None
else:
key = db.Key(parentId)
if (type == 'group'):
group = Group(name=name, parentGroup=key, calendarId=None)
elif (type == 'user'):
group = User(name=name, parentGroup=key, calendarId=None)
key = group.put()
return JsonResponse({'id' : key.__str__() })