本文整理汇总了Python中models.Message.body方法的典型用法代码示例。如果您正苦于以下问题:Python Message.body方法的具体用法?Python Message.body怎么用?Python Message.body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.body方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_messages
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import body [as 别名]
def process_messages(limit):
count = 0
date_parser = dateutil.parser.parser()
omsgs = OriginalMessage.objects()
if limit:
omsgs = omsgs.limit(limit)
for raw_count, om in enumerate(omsgs):
m = Message()
m.body = om.body
m.subFolder = om.subFolder
m.filename = om.filename
m.headers = om.headers
m.subject = om.get_subject()
m.date = date_parser.parse(om.get_date())
m.to = [x for x in om.get_to() if "enron.com" in x]
if not m.to:
# Skip if none of the "To's" are to enron employees
continue
m.from_str = om.get_from()
if "enron.com" not in m.from_str:
# Skip if this email was not from an enron employee
continue
try:
m.save()
except Exception, e:
print "Error trying to save: %s" % (m)
print e
count+=1
if count % 5000 == 0:
print "Processing %s raw messages, filtered to %s" % (raw_count, count)
示例2: forgotpassword
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import body [as 别名]
def forgotpassword():
if request.method == 'POST' and request.form['username']:
try:
userp = User.select().where(User.username==request.form['username']).get()
user = User(
username=request.form['username'],
email=request.form['email'],
password=userp.password
)
msg = Message("Naucilus Support",
sender="[email protected]",
recipients=[user.email])
msg.body = "Hello, " + user.username + "! Your password is: " + userp.password
mail = Mail(app)
mail.send(msg)
return redirect(url_for('index'))
except User.DoesNotExist:
flash('That username does not exist')
return render_template('forgotpassword.html')