本文整理汇总了Python中models.Email.key方法的典型用法代码示例。如果您正苦于以下问题:Python Email.key方法的具体用法?Python Email.key怎么用?Python Email.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Email
的用法示例。
在下文中一共展示了Email.key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: supply
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import key [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())