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


Python Email.all方法代码示例

本文整理汇总了Python中models.Email.all方法的典型用法代码示例。如果您正苦于以下问题:Python Email.all方法的具体用法?Python Email.all怎么用?Python Email.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Email的用法示例。


在下文中一共展示了Email.all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import all [as 别名]
def index(request):
    """
    Generate the front page of spamlibs. This shows the 10 most recent spam
    email messages, and allows users to seed and view them.
    
    :param HttpRequest request: A web request.
    :rtype: An HttpResponse object.
    """
    limit = 10
    
    qry = Email.all().order('-date')
    recent_spams = qry.fetch(limit)
    
    count = qry.count(limit=limit+1)
    
    qry = Email.all().order('-views')
    viewed_spams = qry.fetch(limit)
    
    qry = Email.all().order('-rating')
    popular_spams = qry.fetch(limit)
    
    ctx = RequestContext(request, {
        'recent_spams':recent_spams,
        'viewed_spams':viewed_spams,
        'popular_spams':popular_spams,
        'more':count==limit+1
    })    
    
    return render_to_response('index.html', context_instance=ctx)
开发者ID:dzwarg,项目名称:spamlibs,代码行数:31,代码来源:views.py

示例2: list

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import all [as 别名]
def list(request, page):
    """
    List all the spams in the system, using a paging output.
    
    :param HttpRequest request: A web request.
    :param integer page: The page to view.
    :rtype: An HttpResponse object.
    """
    pagesize = 10
    maxfwd = pagesize * 5 + 1
    
    order = 'date'
    if 'order' in request.GET:
        tmpo = request.GET['order']
        if tmpo[0] == '-':
            tmpo = tmpo[1:]
        if tmpo in Email.properties():
            order = request.GET['order']
    
    page = int(page)
        
    qry = Email.all().order(order)
    nspams = qry.count(offset=(page-1)*pagesize, limit=maxfwd)
    spams = qry.fetch(pagesize, offset=(page-1)*pagesize)
    
    ctx = RequestContext(request, {
        'spams':spams,
        'count':maxfwd,
        'pager':_pager(page, (page-1)*pagesize + nspams, 10),
        'order':order,
        'page':page
    })
    
    return render_to_response('list.html', context_instance=ctx)
开发者ID:dzwarg,项目名称:spamlibs,代码行数:36,代码来源:views.py

示例3: find_existing

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import all [as 别名]
 def find_existing(cls, email):
     hash = hashlib.md5(email).hexdigest()
     found = Account.all().filter("hash =", hash).get()
     if not found:
         found = Account.all().filter("hashes =", hash).get()
     if not found:
         found = Email.all().filter("email =", email).get()
     return found
开发者ID:Mondego,项目名称:pyreco,代码行数:10,代码来源:allPythonContent.py

示例4: post

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import all [as 别名]
    def post(self):
        user = users.get_current_user()
        if user:
            # find if we're already bound to an email
            email_query = Email.all()
            email_query.filter("user =", user)
            email_obj = email_query.get()
            if email_obj:
                add_notify("Notice", "Already bound to an email")
                self.redirect("/")
                return
            # handle the email input
            email_addr = normalize_email(self.request.get("email"))
            if not(email_addr):
                add_notify("Notice", "Not a correct UNI format")
                self.redirect("/")
                return
            # find the email by the email address
            email_key = generate_hash(email_addr)[:10]
            email, made = get_or_make(Email, email_key)
            if not(email.email):
                email.id = email_key
                email.email = email_addr
                email.put()
            # user already tied, don't allow transfers through this interface
            if email.user_enable:
                add_notify("Notice", "User is already enabled")
                self.redirect("/")
                return
            if not(email.user):
                email.user = user
            # generate a new key
            email.user_request_key = generate_random_hash(str(email))
            email.user_request_time = datetime.today()
            email.put()

            # send a verification email
            domain = "http://%s.appspot.com" % get_application_id()
            verify_addr = domain + "/link/email/%s" % email.user_request_key
            msg = mail.EmailMessage()
            fromaddr = "[email protected]%s.appspotmail.com" % get_application_id()
            msg.sender  = "Flyer Guy <%s>" % fromaddr
            msg.to      = email.email
            msg.subject = "[Flyer] Verify your email address"
            msg.html    = template.render("templates/email_verify.html",
                                          {'verify_addr':verify_addr})
            try:
                msg.send()
            except apiproxy_errors.OverQuotaError, (message,):
                # Log the error
                add_notify("Error", "Could not send email")
                logging.error("Could not send email")
                logging.error(message)
            self.redirect("/")
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:56,代码来源:flyer.py

示例5: get

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import all [as 别名]
 def get(self, token):
     # find the email with the token
     email_query = Email.all()
     email_query.filter("user_request_key =", token)
     email = email_query.get()
     # no email, die
     if not(email):
         self.error(404)
     # check the date, if it's late wipe it
     if datetime.today() - email.user_request_time > timedelta(days=2):
         email.user = None
         email.user_request_key = None
         email.user_request_time = None
         email.put()
         self.error(404)
     # enable
     email.user_enable = True
     email.user_request_key = None
     email.user_request_time = None
     email.put()
     add_notify("Notice", "Emails linked!")
     self.redirect("/")
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:24,代码来源:flyer.py

示例6: get_email

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import all [as 别名]
def get_email(user):
    """Get email object associated with user"""
    email_query = Email.all()
    email_query.filter("user = ", user)
    return email_query.get()
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:7,代码来源:flyer.py

示例7: get

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import all [as 别名]
    def get(self):
        timestamp = time.mktime(datetime.now().timetuple())-24*3600
        yesterday = datetime.fromtimestamp(timestamp)
        # count how many flyers are going out
        current_date = datetime.now(CurrentTimeZone())
        day = current_date.weekday() # starts 0=monday... 6=sunday
        if day < 5:
            job_query = Job.all()
            job_query.filter("active =", True)
            job_query.filter("state !=", DONE)
            flyer_count = job_query.count()
        else:
            flyer_count = 0
        # get new clubs
        club_query = Club.all()
        club_query.filter("created_at >", yesterday)
        new_clubs = club_query.fetch(20)
        # get new emails
        email_query = Email.all()
        email_query.filter("created_at >", yesterday)
        new_emails = email_query.fetch(100)
        # get new flyers
        flyer_query = Flyer.all()
        flyer_query.filter("created_at >", yesterday)
        new_flyers = flyer_query.fetch(50)
        # get new EmailToClub
        joint_query = EmailToClub.all()
        joint_query.filter("created_at >", yesterday)
        new_joints = joint_query.fetch(100)
        # and get the newly disabled links
        joint_query = EmailToClub.all()
        joint_query.filter("updated_at >", yesterday)
        joint_query.filter("enable =", False)
        dead_joints = joint_query.fetch(100)

        if (not(new_clubs) and not(new_emails) and not(new_flyers)
            and not(new_joints)):
            self.response.out.write("Nothing to email")
            return

        # email sending pre-computation
        fromaddr = "[email protected]%s.appspotmail.com" % get_application_id()
        date = time.strftime("%Y/%m/%d")

        # send the emails
        msg = mail.EmailMessage(sender = "Flyer Guy <%s>" % fromaddr,
                                to = ADMIN_EMAIL)
        msg.subject = "[Flyer] Admin stats (%s)" % date
        msg.html    = template.render("templates/email_stats.html",
                                      {"flyer_count": flyer_count,
                                       "clubs": new_clubs,
                                       "emails": new_emails,
                                       "flyers": new_flyers,
                                       "joints": new_joints,
                                       "dead_joints": dead_joints})
        try:
            msg.send()
        except apiproxy_errors.OverQuotaError, (message,):
            # Log the error.
            logging.error("Could not send email")
            logging.error(message)
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:63,代码来源:admin.py


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