當前位置: 首頁>>代碼示例>>Python>>正文


Python Email.put方法代碼示例

本文整理匯總了Python中models.Email.put方法的典型用法代碼示例。如果您正苦於以下問題:Python Email.put方法的具體用法?Python Email.put怎麽用?Python Email.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Email的用法示例。


在下文中一共展示了Email.put方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from models import Email [as 別名]
# 或者: from models.Email import put [as 別名]
 def post(self):
     action = self.request.get("action")
     if action == "reset":
         self.account.set_hash_and_key()
     elif action == "addemail":
         email = self.request.get("email")
         if not Email.find_existing(email):
             e = Email(email=self.request.get("email"), account=self.account)
             e.send_activation_email()
             e.put()
     elif action == "removeemail":
         e = Email.get_by_id(int(self.request.get("email-id")))
         if e.account.key() == self.account.key():
             if e.hash() in self.account.hashes:
                 self.account.hashes.remove(e.hash())
                 self.account.put()
             e.delete()
     else:
         if self.request.get("source_enabled", None):
             self.account.source_enabled = True
             self.account.source_name = self.request.get("source_name", None)
             self.account.source_url = self.request.get("source_url", None)
             self.account.source_icon = self.request.get("source_icon", None)
         else:
             self.account.source_enabled = False
     self.account.put()
     self.redirect("/settings")
開發者ID:Mondego,項目名稱:pyreco,代碼行數:29,代碼來源:allPythonContent.py

示例2: supply

# 需要導入模塊: from models import Email [as 別名]
# 或者: from models.Email import put [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())
開發者ID:dzwarg,項目名稱:spamlibs,代碼行數:35,代碼來源:views.py

示例3: incoming

# 需要導入模塊: from models import Email [as 別名]
# 或者: from models.Email import put [as 別名]
def incoming(request):
    """
    Accept a new email message directly via the AppEngine email facility. The
    entire email message is contained in the POST body of *email*.
    
    :param HttpRequest request: A web request.
    :rtype: An HttpResponse object.
    """
    logging.info('Incoming email received.')
    
    try:
        msg = InboundEmailMessage(request.raw_post_data)
        
        usetting = UserSetting.gql('WHERE email = :1', msg.sender)
        if usetting.count() == 0:
            logging.warn('Received email from an unrecognized sender: ' + msg.sender)
            
            return render_to_response('msg_receipt.email', mimetype='text/plain')
            
        if not usetting.get().is_contrib:
            logging.warn('Received email from an unauthorized contributor: ' + msg.sender)
            
            return render_to_response('msg_receipt.email', mimetype='text/plain')
            
        content = ''
        for content_type, body in msg.bodies('text/plain'):
            headers = True
            date = False
            for line in str(body).split('\n'):
                if not date:
                    parts = line.split(' ')
                    line = ' '.join(parts[len(parts)-5:])
                    date = datetime.strptime(line, '%a %b %d %H:%M:%S %Y')
                    logging.debug(str(date))
                    
                if headers and line == '':
                    headers = False
                elif not headers:
                    content += '%s\n' % line
        
        if content == '':
            logging.warn('Received an email, but no text/plain bodies.')
        else:
            logging.info('Compiled plain-text email: body length=%d' % len(content))
            
            newtitle = msg.subject.replace('\n','').replace('\r','')
            content = content.lstrip('\t\n\r ')
            email = Email(title=newtitle, body=content, date=date, views=0, rating=0)
            email.put()
            
            logging.info('Processing new data for tokens & tags')
            
            _process_new(email)
            
    except Exception, ex:
        logging.error('Error processing new email. %s' % ex)
開發者ID:dzwarg,項目名稱:spamlibs,代碼行數:58,代碼來源:views.py


注:本文中的models.Email.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。