本文整理汇总了Python中models.Member.put方法的典型用法代码示例。如果您正苦于以下问题:Python Member.put方法的具体用法?Python Member.put怎么用?Python Member.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Member
的用法示例。
在下文中一共展示了Member.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import put [as 别名]
def post(self, args):
if not require_admin(self):
return
req_id = self.request.get('id')
if not req_id:
self.error(422)
return
member = Member.query(Member.id == req_id).get()
if not member:
member = Member()
member.id = req_id
# Update string values.
for str_param in ['name', 'dce', 'email', 'card_color', 'card_emblem']:
req_val = self.request.get(str_param)
if req_val or req_val == '':
req_val = req_val.strip()
setattr(member, str_param, urllib2.unquote(req_val))
# Update boolean values.
for bool_param in ['show','mailing_list', 'current_student', 'committee_rank', 'merit_rank1', 'merit_rank2', 'card_printed']:
req_val = self.request.get(bool_param)
setattr(member, bool_param, not not req_val)
# Update multi-select values.
member.semesters_paid = [float(semester) for semester in self.request.get('semesters_paid', allow_multiple=True)]
# Save the updated member.
member.put()
if member.never_paid:
self.redirect('/members/hidden', code=303)
return
self.redirect('/members/' + member.id, code=303)
示例2: get
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import put [as 别名]
def get(self):
handle = self.request.get('handle', None)
if handle is None:
# First request, just get the first handle out of the datastore.
hacker = Hacker.gql('ORDER BY handle DESC').get()
if not hacker:
# No hackers in database
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write("No Hackers in database")
return
handle = hacker.handle
query = Hacker.gql('WHERE handle <= :1 ORDER BY handle DESC', handle)
hackers = query.fetch(limit=2)
current_hacker = hackers[0]
if len(hackers) == 2:
next_handle = hackers[1].handle
next_url = '/admin/hacker_migration?handle=%s' % urllib.quote(next_handle)
else:
next_handle = 'FINISHED'
next_url = '/' # Finished processing, go back to main page.
awards_updated = 0
talks_updated = 0
updated_hacker = False
# Add a new member if this Hacker has not been migrated
if not Member.gql('WHERE handle = :1', current_hacker.handle).get():
new_member = Member(user_id=current_hacker.user_id,
email=current_hacker.email,
handle=current_hacker.handle,
bio=current_hacker.bio,
real_name=current_hacker.real_name)
new_member.put()
# Find any award or talk entities that reference the old hacker
# and remap them
awards = Award.gql('WHERE hacker = :1', current_hacker)
for award in awards:
award.member = new_member
if hasattr(award, 'hacker'):
del award.hacker
award.put()
awards_updated += 1
talks = Talk.gql('WHERE member = :1', current_hacker)
for talk in talks:
talk.member = new_member
talk.put()
talks_updated += 1
updated_hacker = True
# Delete the Hacker
current_hacker.delete()
context = {
'current_handle': handle,
'updated_hacker': updated_hacker,
'awards_updated': awards_updated,
'talks_updated': talks_updated,
'next_handle': next_handle,
'next_url': next_url,
}
self.render_template('hacker_migration', context)