当前位置: 首页>>代码示例>>Python>>正文


Python Email.get方法代码示例

本文整理汇总了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)
开发者ID:dzwarg,项目名称:spamlibs,代码行数:55,代码来源:views.py

示例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
开发者ID:dzwarg,项目名称:spamlibs,代码行数:15,代码来源:views.py

示例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')
开发者ID:dzwarg,项目名称:spamlibs,代码行数:19,代码来源:views.py


注:本文中的models.Email.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。