-
Notifications
You must be signed in to change notification settings - Fork 40
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
Conversation
@@ -16,6 +16,20 @@ | |||
from pyramid_mailer._compat import SMTP_SSL | |||
|
|||
|
|||
def _check_bind_options(kw): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
LGTM, thank you @dairiki. |
This adds stub
DebugMailer.bind()
andDummyMailer.bind()
methods. (#82)Also it fixes
pyramid_mailer.debug.includeme()
, andpyramid_mailer.testing.includeme()
to add the.mailer
request property. (#79)Review welcome.