当前位置: 首页>>代码示例>>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;未经允许,请勿转载。