本文整理汇总了Python中models.Email.get方法的典型用法代码示例。如果您正苦于以下问题:Python Email.get方法的具体用法?Python Email.get怎么用?Python Email.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Email
的用法示例。
在下文中一共展示了Email.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: seed
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import get [as 别名]
def seed(request, key):
"""
Provide a form to seed, or populate, the libs for a specific spam email.
The email message is specified by *key*. If the specified email cannot be
found, this raises a 404 error.
:param HttpRequest request: A web request.
:param string key: The identifier for a specific email.
:rtype: An HttpResponse object.
"""
try:
email = Email.get(key)
except BadKeyError:
raise Http404
email.views += 1
email.put()
if request.method == 'GET':
libs = Lib.all().filter('email =', email).order('position')
ctx = RequestContext(request, {
'title':email.title,
'key':key,
'libs':libs
})
return render_to_response('seed_fields.html', context_instance=ctx)
ls = []
for l in request.POST.items():
ls.append( (l[0], l[1], Lib.get(l[0]),) )
ls.sort(cmp=lambda x,y: cmp(x[2].position, y[2].position))
newbody = ''
bodyidx = 0
for l in ls:
newbody += email.body[bodyidx:l[2].position]
bodyidx = l[2].position
newbody += l[1]
bodyidx += len(l[2].original)
newbody += email.body[bodyidx:]
ctx = RequestContext(request, {
'key':key,
'title':email.title,
'body':newbody,
'is_processed':True,
'views':email.views
})
return render_to_response('output_raw.html', context_instance=ctx)
示例2: view
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import get [as 别名]
def view(request, key):
"""
View an original spam email message. The email message is specified by *key*.
If the specified email cannot be found, this raises a 404 error.
:param HttpRequest request: A web request.
:param string key: The identifier for a specific email.
:rtype: An HttpResponse object.
"""
try:
email = Email.get(key)
except BadKeyError, ex:
raise Http404
示例3: rate
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import get [as 别名]
def rate(request, key):
"""
Rate a spam-libbed spam email.
:param HttpRequest request: A web request.
:param string key: The identifier for a specific email.
:rtype: An HttpResponse object
"""
try:
email = Email.get(key)
except BadKeyError:
raise Http404
email.rating += 1;
email.put()
return HttpResponse('OK')