本文整理汇总了Python中fivecents.lib.i18n.Messages.messageWasSent方法的典型用法代码示例。如果您正苦于以下问题:Python Messages.messageWasSent方法的具体用法?Python Messages.messageWasSent怎么用?Python Messages.messageWasSent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fivecents.lib.i18n.Messages
的用法示例。
在下文中一共展示了Messages.messageWasSent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_invitation
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import messageWasSent [as 别名]
def send_invitation(self):
model = self.get_sa_model()
db = self.get_sa_session()
if not authorized(ValidAuthKitUser()):
return { "failure" : Messages.invalidSession() }
to_address = request.params.get('to_address')
body = request.params.get('body')
if not to_address or not body:
return { "failure" : Messages.invalidArguments() }
invitation = db.query(model.Invitation).filter_by(to_address = to_address).filter_by(sender_uid=h.authenticated_user().uid).first()
if invitation:
invitation.message = body
invitation.sent = False
invitation.sent_on = datetime.today()
else:
invitation = model.Invitation(
sender_uid = h.authenticated_user().uid,
to_address = to_address,
message = body
)
db.save(invitation)
db.commit()
return { "success" : Messages.messageWasSent() }
示例2: send_feedback
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import messageWasSent [as 别名]
to_address = to_address,
message = body
)
db.save(invitation)
db.commit()
return { "success" : Messages.messageWasSent() }
@rest.restrict("POST")
@jsonify
def send_feedback(self):
from_address = request.params.get('from_address')
subject = _("Feedback about %s ") % h.site_name()
body = request.params.get('body')
if not from_address or not subject or not body:
return { "failure" : Messages.invalidArguments() }
from email.MIMEText import MIMEText
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = from_address
message['To'] = config['email_to']
try:
from fivecents.lib.mail import EmailSender
ms = EmailSender(to_addresses = message['To'])
ms.send_mime(message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }
return { "success" : Messages.messageWasSent() }