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


Python Message.sender方法代码示例

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


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

示例1: mark_complete

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import sender [as 别名]
def mark_complete():
    """
    Checks to see if a group exists in FAS for the given project and marks the
    project complete if it does. We do this this way so that we don't have to
    send FAS credentials to this app.
    """
    fas = fedora.client.AccountSystem(app.config['FAS_SERVER'],
                                      username=app.config['FAS_USERNAME'],
                                      password=app.config['FAS_PASSWORD'],
                                      insecure=app.config['FAS_INSECURE_SSL'])
    hosted_request = HostedRequest.query.filter_by(id=request.args.get('id'))
    if hosted_request.count() > 0:
        project = hosted_request[0]
        if project.completed:
            return jsonify(error="Request was already marked as completed.")

        group_name = project.scm + project.name
        try:
            group = fas.group_by_name(group_name)
        except:
            return jsonify(error="No such group: " + group_name)

        project.completed = datetime.now()
        db.session.commit()
        message = Message("Your Fedora Hosted request has been processed")
        message.body = """Hi there,

You're receiving this message because the Fedora Hosted project:
  %s
has been set up.

To access to your new repository, do the following:
  $ %s

If you've requested a Trac instance, you can visit it at:
  https://fedorahosted.org/%s

If you've requested any mailing lists, you should have received separate
emails which contain instructions on how to administrate them.

Sincerely,
Fedora Hosted""" % (
            project.name,
            scm_push_instructions(project),
            project.name)

        message.sender = \
            "Fedora Hosted <[email protected]>"

        if 'PROJECT_OWNER_EMAIL_OVERRIDE' in app.config:
            message.recipients = [app.config['PROJECT_OWNER_EMAIL_OVERRIDE']]
        else:
            message.recipients = ["%[email protected]" % project.owner]

        if not app.config['TESTING']:
            mail.send(message)

        return jsonify(success="Request marked as completed.")
    else:
        return jsonify(error="No hosted request with that ID could be found.")
开发者ID:relrod,项目名称:fedorahosted,代码行数:62,代码来源:main.py

示例2: send

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import sender [as 别名]
def send(file_id):
  recipient = request.form.get("recipient")
  f = get_file(file_id)

  msg = Message("File sent from Yaka")
  msg.sender = g.user.email
  msg.recipients = [recipient]
  msg.body = """The following file (%s) might be interesting to you.

  """ % f.name

  msg.attach(f.name, f.mime_type, f.data)

  mail.send(msg)
  flash("Email successfully sent", "success")

  return redirect(ROOT + "%d" % f.uid)
开发者ID:sfermigier,项目名称:yaka,代码行数:19,代码来源:dm.py

示例3: hello

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import sender [as 别名]
def hello():
    form = RequestForm()
    if form.validate_on_submit():
        # The hosted request itself (no mailing lists)
        hosted_request = HostedRequest(
            name=form.project_name.data,
            pretty_name=form.project_pretty_name.data,
            description=form.project_description.data,
            scm=form.project_scm.data,
            trac=form.project_trac.data,
            owner=form.project_owner.data,
            comments=form.comments.data)
        db.session.add(hosted_request)
        db.session.commit()

        # Mailing lists
        for entry in form.project_mailing_lists.entries:
            if entry.data:
                # The field wasn't left blank...
                list_name = entry.data

                # The person only entered the list name, not the full address.
                if not list_name.endswith("@lists.fedorahosted.org"):
                    list_name = list_name + "@lists.fedorahosted.org"

                mailing_list = MailingList.find_or_create_by_name(list_name)

                # The last step before storing the list is handling
                # commit lists -- lists that get commit messages -- which also
                # appear as regular lists.
                commit_list = False
                if list_name in form.project_commit_lists.entries:
                    del form.project_commit_lists.entries[list_name]
                    commit_list = True

                # Now we have a mailing list object (in mailing_list), we can
                # store the relationship using it.
                list_request = ListRequest(
                    mailing_list=mailing_list,
                    hosted_request=hosted_request,
                    commit_list=commit_list)
                db.session.add(list_request)
                db.session.commit()

        # Add the remaining commit list entries to the project.
        for entry in form.project_commit_lists.entries:
            if entry.data:
                mailing_list = MailingList.find_or_create_by_name(entry.data)
                list_request = ListRequest(
                    mailing_list=mailing_list,
                    hosted_request=hosted_request,
                    commit_list=True)
                db.session.add(list_request)
                db.session.commit()

        # Tell some people that the request has been made.
        message = Message("New Fedora Hosted project request")
        message.body = """Members of sysadmin-hosted,

A new Fedora Hosted request, id %s,  has been made.
To process this request, please do the following:

$ ssh fedorahosted.org
$ fedorahosted -n -p %s    # No-op. Review this and make sure the output looks
                          # sane.

$ sudo fedorahosted -p %s  # Actually process the request.

Thanks,
Fedora Hosted automation system""" % (hosted_request.id,
                                      hosted_request.id,
                                      hosted_request.id)
        message.recipients = [app.config['NOTIFY_ON_REQUEST']]
        message.sender = \
            "Fedora Hosted <[email protected]>"
        if not app.config['TESTING']:
            mail.send(message)

        return render_template('completed.html')

    # GET, not POST.
    return render_template('index.html', form=form)
开发者ID:relrod,项目名称:fedorahosted,代码行数:84,代码来源:main.py


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