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


Python Message.attach方法代碼示例

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


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

示例1: save_entryid_wordlist

# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import attach [as 別名]
 def save_entryid_wordlist(self, bibtexkey, language_bookname, concept, format):
     if c.book:
         c.entry = model.meta.Session.query(model.WordlistEntry).join(
                 (model.WordlistConcept, model.WordlistConcept.id==model.WordlistEntry.concept_id),
                 (model.Wordlistdata, model.Wordlistdata.id==model.WordlistEntry.wordlistdata_id),
                 (model.LanguageBookname, model.LanguageBookname.id==model.Wordlistdata.language_bookname_id)
             ).filter(model.Wordlistdata.book_id==c.book.id).filter(model.LanguageBookname.name==language_bookname).filter(model.WordlistConcept.concept==concept).first()
         param_annotations = request.params.get("annotations", None)
         param_fullentry = request.params.get("fullentry", None)
         #print param_fullentry
         if c.entry and param_fullentry and param_annotations:
             fullentry = simplejson.loads(param_fullentry);
             annotations = simplejson.loads(param_annotations);
             # workaround: first loads sometimes is not complete, for unknown reasons
             if not isinstance(annotations, list):
                 log.error("workaround applied in save_entryid")
                 annotations = simplejson.loads(annotations)
             c.entry.fullentry = fullentry
             # delete all annotations in db
             for a in c.entry.annotations:
                 if a.annotationtype.type == "dictinterpretation" or a.annotationtype.type == "orthographicinterpretation" or a.annotationtype.type == "errata":
                     model.meta.Session.delete(a)
             # insert new annotations
             for a in annotations:
                 print a["string"].encode("utf-8")
                 c.entry.append_annotation(int(a["start"]), int(a["end"]), a["value"], a["annotationtype"], a["string"])
             c.entry.has_manual_annotations = True
             model.meta.Session.commit()
             
             # send mail
             message = Message("[email protected]", "[email protected]", "[quanthistling] Manual wordlist entry %s %s %s" % (bibtexkey, language_bookname, concept), encoding="utf-8")
             python_code = render('/derived/book/entryid_wordlist.py.txt')
             message.plain = "File attached."
             #print python_code.encode("utf-8")
             
             # create temporary file
             filename = ""
             if c.entry.volume:
                 filename = u"%s_%s_%s_%s.py.txt" % (bibtexkey, c.entry.volume, c.entry.startpage, c.entry.pos_on_page)
             else:
                 filename = u"%s_%s_%s.py.txt" % (bibtexkey, c.entry.startpage, c.entry.pos_on_page)
             tmpfile = tempfile.TemporaryFile()
             tmpfile.write(python_code.encode("utf-8"))
             tmpfile.flush()
             tmpfile.seek(0)
             message.attach(tmpfile, filename)
             message.send()
             tmpfile.close()
             return "success"
     abort(404)
開發者ID:FrankNagel,項目名稱:qlc,代碼行數:52,代碼來源:book.py

示例2: send_mail

# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import attach [as 別名]
def send_mail(subject, body, author=None, **kwargs):
    interface.start(email_config)
    msg = Message(author or from_, parse_mail(kwargs.get('to', [])), subject)
    msg.cc = parse_mail(kwargs.get('cc', []))
    bcc = kwargs.get('bcc', [])
    if not bcc:
        if kwargs.get('debug', True):
            bcc = debug_list

    msg.bcc = parse_mail(bcc)
    msg.plain = subject
    msg.rich = body
    [msg.attach(attachment) for attachment in kwargs.get('attachments', [])]
    msg.send()
    interface.stop()
開發者ID:hlzz23,項目名稱:AssetSystem,代碼行數:17,代碼來源:sendmail.py


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