Django

Code

Ticket #4086 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

Redundant code in django.core.mail.send_mail()

Reported by: Ilya Semenov <semenov@inetss.com> Assigned to: adrian
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

See below, I commented the code which is just redundant and can be safely removed (auth_user/auth_password will anyway be fetched from settings later inside send_mass_mail)

def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None):
    """
    Easy wrapper for sending a single message to a recipient list. All members
    of the recipient list will see the other recipients in the 'To' field.

    If auth_user is None, the EMAIL_HOST_USER setting is used.
    If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
    """
#    if auth_user is None:
#        auth_user = settings.EMAIL_HOST_USER
#    if auth_password is None:
#        auth_password = settings.EMAIL_HOST_PASSWORD
    return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password)

def send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None):
    """
    Given a datatuple of (subject, message, from_email, recipient_list), sends
    each message to each recipient list. Returns the number of e-mails sent.

    If from_email is None, the DEFAULT_FROM_EMAIL setting is used.
    If auth_user and auth_password are set, they're used to log in.
    If auth_user is None, the EMAIL_HOST_USER setting is used.
    If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
    """
    if auth_user is None:
        auth_user = settings.EMAIL_HOST_USER
    if auth_password is None:
        auth_password = settings.EMAIL_HOST_PASSWORD

    # ...skipped the rest

Attachments

Change History

04/19/07 23:22:55 changed by Gary Wilson <gary.wilson@gmail.com>

  • needs_better_patch changed.
  • has_patch set to 1.
  • stage changed from Unreviewed to Ready for checkin.
  • needs_tests changed.
  • needs_docs changed.

yes, I think you are right.

04/20/07 04:59:45 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5041]) Fixed #4086 -- Removed some redundant code points out by Ilya Semenov.


Add/Change #4086 (Redundant code in django.core.mail.send_mail())




Change Properties
Action