本文整理汇总了Python中model.Member.put方法的典型用法代码示例。如果您正苦于以下问题:Python Member.put方法的具体用法?Python Member.put怎么用?Python Member.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Member
的用法示例。
在下文中一共展示了Member.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import put [as 别名]
def post(self):
if self.request.get('store') != '1':
self.redirect('/members')
return
try:
member = Member()
member.name = self.get_var('name')
member.address = self.get_var('address')
member.zipcode = self.get_var('zip')
member.city = self.get_var('city')
member.country = Country.get(self.get_var('country'))
member.email = self.get_var('email', optional=True)
member.mobile = self.get_var('mobile', optional=True)
member.home = self.get_var('home', optional=True)
member.work = self.get_var('work', optional=True)
member.membertype = MemberType.get(self.get_var('type'))
member.notes = self.get_var('comment', optional=True)
member.status = Status.get(self.get_var('status'))
member.number = dbutils.create_new_member_no()
member.member_since = datetime.date.today()
member.generate_access_code()
mcount = self.get_var('magazine_count', optional=True)
member.magazine_count = int(mcount) if mcount else 1
member.put()
self.redirect('/members/%s/edit' % member.key())
return
except MissingField:
# TODO: Redirect
template = JINJA_ENVIRONMENT.get_template('templates/members/new_member.html')
countries = Country.all().order('order').fetch(LIMIT)
statuses = Status.all().order('order').fetch(LIMIT)
types = MemberType.all().order('order').fetch(LIMIT)
data = { }
for name in [ 'name', 'address', 'zip', 'country', 'email', 'mobile', 'home', 'work', 'type', 'comment', 'status']:
data[name] = self.request.get(name)
params = {
'countries': countries,
'statuses': statuses,
'types': types,
'data': data
}
self.response.write(template.render(params))
return
self.redirect('/members')
示例2: post
# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import put [as 别名]
def post(self):
req_user = self.request.user
gu_obj = GoogleUser.get_or_insert(req_user.user_id())
if gu_obj.name:
self.redirect('/')
return
errors = []
name = self.POST['name'].strip().lower()
if name:
if len(name)<20:
if re.search('^[a-zA-Z0-9]+$', name):
check_obj = Member.get_by_key_name(str(name))
if check_obj:
errors.append('该用户名已被注册,请换一个吧')
else:
#get member id
mid_obj = Counter.get_or_insert('member_auto_increment',name = 'member_auto_increment', value = 1)
nuser_obj = Member(key_name=name, id = mid_obj.value, flag = 1, add = int(time()))
nuser_obj.put()
if nuser_obj.is_saved():
#set google user
gu_obj.name = name
db.run_in_transaction(obj_runput,gu_obj)
#all member num +1
mid_obj.value += 1
db.run_in_transaction(obj_runput,mid_obj)
self.redirect('/setavatar')
return
else:
errors.append('服务器出现意外错误,请稍后再试')
else:
errors.append('用户名只能包含字母和数字')
else:
errors.append('用户名太长了')
else:
errors.append('用户名必填')
self.echo('setname.html', {
'title': "设置名字",
'errors':errors,
'name':name,
'newest_node': Node.get_newest(),
}, layout='_layout.html')
示例3: task_member_restore
# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import put [as 别名]
def task_member_restore(items):
for item in items:
member = Member()
member.number = item['number']
member.address = item['address']
if item['email'] != '' and item['email'] != None:
member.email = db.Email(item['email'])
member.name = item['name']
member.member_since = string_to_date(item['memberSince'])
if item['phone'] != '' and item['phone'] != None:
member.phone = db.PhoneNumber(item['phone'])
if item['phoneWork'] != '' and item['phoneWork'] != None:
member.phone_work = item['phoneWork']
if item['phoneHome'] != '' and item['phoneHome'] != None:
member.phone_home = item['phoneHome']
member.notes = item['notes']
member.zipcode = item['zipcode']
member.city = item['city']
member.county = item['county']
member.country = db.get(db.Key.from_path('Country', item['countryId']))
member.status = db.get(db.Key.from_path('Status', item['statusId']))
member.membertype = db.get(db.Key.from_path('MemberType', item['typeId']))
member.put()
for itemdue in item['membershipDues']:
due = MembershipDues(parent=member, year=itemdue['year'],paid=itemdue['paid'])
due.put()
for itemcar in item['cars']:
car = Car()
car.member = member
car.registration = itemcar['registration']
car.model = db.get(db.Key.from_path('CarModel', itemcar['modelId']))
car.bought_year = itemcar['boughtYear']
car.sold_year = itemcar['soldYear']
car.year = itemcar['year']
car.notes = itemcar['notes']
car.serial_no = itemcar['serialNo']
car.put()
示例4: import_members
# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import put [as 别名]
def import_members(self, member_csv):
member_csv = member_csv.split('\n')
lines = self.unmangle(member_csv)
count = 0
for fields in lines:
#fields.reverse()
print '-'*80
print fields
print '='*80
fields.reverse()
member = Member()
(fee2009, fee2010, fee2011,
fee2012, fee2013, fee2014) = (
fields.pop(), fields.pop(), fields.pop(),
fields.pop(), fields.pop(), fields.pop())
member.address = fields.pop()
# Skip the cars
for carno in range(1,6):
(car, registration) = (fields.pop(), fields.pop())
email = fields.pop()
if email != '':
member.email = db.Email(email)
(lastname, firstname) = (fields.pop(), fields.pop())
full_name = firstname + ' ' + lastname
member.name = full_name.strip()
member.county = fields.pop().strip()
member_since = fields.pop()
date = self.string_to_date(member_since)
if date:
member.member_since = date
else:
print 'Error converting date from',member_since
country = fields.pop().strip()
if country == '':
country = 'Norge'
member.country = self.string_to_country(country)
member.membertype = self.string_to_type(fields.pop())
member.number = fields.pop()
mobile = fields.pop()
if mobile != '':
member.phone = db.PhoneNumber(mobile)
member.notes = fields.pop()
member.zipcode = fields.pop()
member.city = fields.pop()
work = fields.pop()
home = fields.pop()
if work != '':
member.phone_work = db.PhoneNumber(work)
if home != '':
member.phone_home = db.PhoneNumber(home)
member.status = self.get_status('Medlem')
member.generate_access_code()
member.put()
self.add_due(member, 2009, fee2009=='Betalt')
self.add_due(member, 2010, fee2010=='Betalt')
self.add_due(member, 2011, fee2011=='Betalt')
self.add_due(member, 2012, fee2012=='Betalt')
self.add_due(member, 2013, fee2013=='Betalt')
self.add_due(member, 2014, fee2014=='Betalt')
count = count + 1
print 'Imported',count,'members'