本文整理匯總了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())