Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow just html_body and text_body for send_email #879

Closed
wants to merge 1 commit into from

3 participants

@fayazkhan

A patch for i878 (#878)

@gtaylor

In what case would to_addresses be optional?

That is a side-effect of the parameter ordering. I agree that it is undesirable. I'm willing to add a check somewhere in there and write proper unit tests to make sure they're always ensured, provided somebody told me how to write a test for the ses module as this module seems to be missing any tests at all.

Collaborator

keyword args are optional in Python, this breaks down the moment you require an optional keyword arg. I'd suggest thinking of another approach for this.

Could you clarify? I don't see a breakage as far as 'to_addresses' is present in the arguments. I could add a check to make sure it is non-empty and raise some helpful exception on the contrary case. The 'body' CAN be empty, as far as text_body or html_body or both of those are present.

Collaborator

A keyword arg (such as to_address and body in your modified version) infers that it is optional. A positional argument, or a parameter, is required (source, subject). Adding a check to make sure an optional keyword arg is specified violates the whole point of an optional keyword arg. That is exactly what a positional/parameter is for.

So the bad thing about changing body and to_address to be optional kwargs is that our users will see that these are optional, and wonder what on earth is up. When you would ever want to use send_email with an empty to_address (no recipient?) or empty body (no content?).

I hear you.

@garnaat garnaat closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 21, 2012
  1. @fayazkhan
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  boto/ses/connection.py
View
2  boto/ses/connection.py
@@ -167,7 +167,7 @@ def _handle_error(self, response, body):
raise ExceptionToRaise(response.status, exc_reason, body)
- def send_email(self, source, subject, body, to_addresses,
+ def send_email(self, source, subject, body=None, to_addresses=None,
cc_addresses=None, bcc_addresses=None,
format='text', reply_addresses=None,
return_path=None, text_body=None, html_body=None):
Something went wrong with that request. Please try again.