本文整理汇总了Python中models.Email.put方法的典型用法代码示例。如果您正苦于以下问题:Python Email.put方法的具体用法?Python Email.put怎么用?Python Email.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Email
的用法示例。
在下文中一共展示了Email.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import put [as 别名]
def post(self):
action = self.request.get("action")
if action == "reset":
self.account.set_hash_and_key()
elif action == "addemail":
email = self.request.get("email")
if not Email.find_existing(email):
e = Email(email=self.request.get("email"), account=self.account)
e.send_activation_email()
e.put()
elif action == "removeemail":
e = Email.get_by_id(int(self.request.get("email-id")))
if e.account.key() == self.account.key():
if e.hash() in self.account.hashes:
self.account.hashes.remove(e.hash())
self.account.put()
e.delete()
else:
if self.request.get("source_enabled", None):
self.account.source_enabled = True
self.account.source_name = self.request.get("source_name", None)
self.account.source_url = self.request.get("source_url", None)
self.account.source_icon = self.request.get("source_icon", None)
else:
self.account.source_enabled = False
self.account.put()
self.redirect("/settings")
示例2: supply
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import put [as 别名]
def supply(request):
"""
If the HTTP Verb is GET: Provide a form for adding a new spam email message.
If the HTTP Verb is POST: Save and process a new email message, and view
the resulting message.
:param HttpRequest request: A web request.
:rtype: An HttpResponse object.
"""
user = users.get_current_user()
if user is None:
return redirect(users.create_login_url('/supply'))
usetting = UserSetting.gql('WHERE userid = :1', user.user_id())
if usetting.count() != 1 or not usetting.get().is_contrib:
return HttpResponseForbidden('<h1>Authorization Required</h1>')
if request.method == 'GET':
ctx = RequestContext(request, {})
return render_to_response('input_form.html', context_instance=ctx)
title = request.POST['title']
input = request.POST['input'].lstrip('\t\n\r ')
date = datetime.now()
email = Email(title=title, body=input, date=date, views=0, rating=0)
email.put()
_process_new(email)
return redirect('/view/%s' % email.key())
示例3: incoming
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import put [as 别名]
def incoming(request):
"""
Accept a new email message directly via the AppEngine email facility. The
entire email message is contained in the POST body of *email*.
:param HttpRequest request: A web request.
:rtype: An HttpResponse object.
"""
logging.info('Incoming email received.')
try:
msg = InboundEmailMessage(request.raw_post_data)
usetting = UserSetting.gql('WHERE email = :1', msg.sender)
if usetting.count() == 0:
logging.warn('Received email from an unrecognized sender: ' + msg.sender)
return render_to_response('msg_receipt.email', mimetype='text/plain')
if not usetting.get().is_contrib:
logging.warn('Received email from an unauthorized contributor: ' + msg.sender)
return render_to_response('msg_receipt.email', mimetype='text/plain')
content = ''
for content_type, body in msg.bodies('text/plain'):
headers = True
date = False
for line in str(body).split('\n'):
if not date:
parts = line.split(' ')
line = ' '.join(parts[len(parts)-5:])
date = datetime.strptime(line, '%a %b %d %H:%M:%S %Y')
logging.debug(str(date))
if headers and line == '':
headers = False
elif not headers:
content += '%s\n' % line
if content == '':
logging.warn('Received an email, but no text/plain bodies.')
else:
logging.info('Compiled plain-text email: body length=%d' % len(content))
newtitle = msg.subject.replace('\n','').replace('\r','')
content = content.lstrip('\t\n\r ')
email = Email(title=newtitle, body=content, date=date, views=0, rating=0)
email.put()
logging.info('Processing new data for tokens & tags')
_process_new(email)
except Exception, ex:
logging.error('Error processing new email. %s' % ex)