本文整理汇总了Python中pyramid_simpleform.Form.data['email']方法的典型用法代码示例。如果您正苦于以下问题:Python Form.data['email']方法的具体用法?Python Form.data['email']怎么用?Python Form.data['email']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid_simpleform.Form
的用法示例。
在下文中一共展示了Form.data['email']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: account
# 需要导入模块: from pyramid_simpleform import Form [as 别名]
# 或者: from pyramid_simpleform.Form import data['email'] [as 别名]
def account(user, request):
'''Shows the user account modification page'''
form = Form(request, schema=AccountSchema,
state=State(db=request.db, user_id=authenticated_userid(request))
)
if form.validate():
body = "Thank your account has been updated.\n"
if form.data['password']:
body = body + "Your new password is: %s" % form.data['password']
password_hash, salt = hash_password(form.data['password'])
user['password_hash'] = password_hash
user['salt'] = salt
if form.data['email'] and user['email'].lower() != form.data['email']:
body = body + "Your email has changed from %s to %s\n"\
% (user['email'], form.data['email'])
user['email'] = form.data['email'].lower()
mailer = request.registry['mailer']
office_email = request.registry.settings['office.email']
from_ = "%s <%s>" % ("Formative", office_email)
message = Message(
subject='Account modified',
sender=office_email,
recipients=[user['email']],
body=body,
extra_headers = {"From": from_}
)
mailer.send_immediately(message)
request.session.flash('Account information changed.', queue='info')
# Fill in the users email
if 'email' not in form.data:
form.data['email'] = user['email']
# Remove password
form.data['password'] = ''
return {"renderer":FormRenderer(form)}