Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for #82 and #79 #83

Merged
merged 6 commits into from
Dec 13, 2016
Merged

Fixes for #82 and #79 #83

merged 6 commits into from
Dec 13, 2016

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Dec 12, 2016

This adds stub DebugMailer.bind() and DummyMailer.bind() methods. (#82)
Also it fixes pyramid_mailer.debug.includeme(), and pyramid_mailer.testing.includeme() to add the .mailer request property. (#79)

Review welcome.

@@ -16,6 +16,20 @@
from pyramid_mailer._compat import SMTP_SSL


def _check_bind_options(kw):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be called for the default Mailer as well, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. Right now Mailer.bind does its own equivalent checks, so the call would be redundant. (Those checks are intertwingled with the extraction of the pertinent parameters.)

Another way to go, which I considered initially, would be to have a common _extract_bind_options that gets called by all three .bind methods which does both the check and the extraction of the default_sender and transaction_manager options. (The extracted parameters would then be ignored by everyone except Mailer.bind.) The ugliness with doing that has to do with the way the default values for these options is determined: in the real Mailer, defaults for these come from object properties; in the dummy/debug mailers, these parameters, ignored as they are, have indeterminate (or inconsequential) default values. (If that makes any sense...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would argue that for consistency you should call _check_bind_options from Mailer.bind and separate the checking from the popping.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Done.)



def set_mailer(config, mailer):
"""Set mailer in application config.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be named with an underscore (_set_mailer) to emphasize that it is not published API?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine if you want. Alternatively it could be a full-blown config.set_mailer directive, but we can save that for later so maybe _set_mailer for now.

@mmerickel mmerickel merged commit 5bc8cd7 into Pylons:master Dec 13, 2016
@mmerickel
Copy link
Member

LGTM, thank you @dairiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants