本文整理汇总了Python中fivecents.lib.i18n.Messages.invalidSession方法的典型用法代码示例。如果您正苦于以下问题:Python Messages.invalidSession方法的具体用法?Python Messages.invalidSession怎么用?Python Messages.invalidSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fivecents.lib.i18n.Messages
的用法示例。
在下文中一共展示了Messages.invalidSession方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_invitation
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import invalidSession [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_email
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import invalidSession [as 别名]
def send_email(self):
"""
Will send an e-mail with to a given address.
Only authenticated users can use it.
"""
if not authorized(ValidAuthKitUser()):
return { "failure" : Messages.invalidSession() }
to_address = request.params.get('to_address')
subject = request.params.get('subject')
body = request.params.get('body')
if not to_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'] = config['from_address']
message['To'] = to_address
try:
self.emailSender().send_mime(to_address, config['from_address'], message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }
示例3: send_email
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import invalidSession [as 别名]
def send_email(self):
if not authorized(ValidAuthKitUser()):
return { "failure" : Messages.invalidSession() }
try:
to_address = request.params['to_address']
subject = request.params['subject']
body = request.params['body']
except:
return { "failure" : Messages.invalidArguments() }
if to_address == "" or subject == "" or body == "":
return { "failure" : Messages.invalidArguments() }
from email.MIMEText import MIMEText
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = config['from_address']
message['To'] = to_address
try:
from fivecents.lib.mail import EmailSender
ms = EmailSender(to_addresses = to_address)
ms.send_mime(message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }
示例4: send_invitation
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import invalidSession [as 别名]
def send_invitation(self):
model = request.environ["sqlalchemy.model"]
db = request.environ["sqlalchemy.session"]
if not authorized(ValidAuthKitUser()):
return { "failure" : Messages.invalidSession() }
try:
to_address = request.params['to_address']
subject = _("You have been invited to %s " % h.site_name())
body = request.params['body']
except:
return { "failure" : Messages.invalidArguments() }
if to_address == "" or subject == "" or body == "":
return { "failure" : Messages.invalidArguments() }
invitation = model.Invitation(
sender_uid = h.authenticated_user().uid,
to_address = to_address,
)
db.save(invitation)
db.commit()
c.invitation_link = h.site_url() + h.url_for(controller='signup', action='invitation', id=invitation.token)
from email.MIMEText import MIMEText
body = body + render_jinja('messages/invitation_footer.jinja')
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = config['from_address']
message['To'] = to_address
try:
from fivecents.lib.mail import EmailSender
ms = EmailSender(to_addresses = to_address)
ms.send_mime(message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }