Repository navigation
Adds support for Django 6.1 MAILERS - #661
a-musing-moose wants to merge 1 commit into
Conversation
|
Maybe better to merge that rather than waiting for a perfect implementation? Moreover, no specific examples of what needs to be added are provided here. |
6f55de9 to
563a909
Compare
Good suggested @codingjoe, and sorry for the long wait. I have updated my PR with an additional commit. This one introduces an Let me know if there is anything else you would like to see refined on this. |
codingjoe
left a comment
There was a problem hiding this comment.
Nice, that looks promising. I haven't done a full review, since you added a lot of unrelated formatting changes. Ping me, when you need another review.
| :py:meth:`~.environ.Env.email_url`, but returns one Django 6.1 ``MAILERS`` | ||
| entry with ``BACKEND`` and lowercase ``OPTIONS`` keys. The ``mailer`` method | ||
| is an alias for ``mailer_url``. | ||
|
|
||
| Pass ``extra_options`` to either method to add options that are awkward to | ||
| encode in a URL or to override URL-derived values. Extra option keys should | ||
| use the lowercase Django mailer option names, and their values are preserved | ||
| without casting: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| config = env.mailer_url(extra_options={ | ||
| "use_tls": False, | ||
| "custom_option": {"retries": 3}, | ||
| }) | ||
|
|
||
| The extra values are merged into ``OPTIONS`` after URL parsing, so they take | ||
| precedence over options from the URL. |
There was a problem hiding this comment.
Might I suggest adding a full example including the output?
>>> MAILERS = {"default": env.mailer_url(extra_options={
... "use_tls": False,
... "custom_option": {"retries": 3},
...})}
>>> print(MAILERS)
{…}That might be more descriptive than most of the prose.
There was a problem hiding this comment.
A good idea, hopefully what I have now added makes things clearer
There was a problem hiding this comment.
That fails contains a lot of unrelated reformatting; please drop it from your changeset.
There was a problem hiding this comment.
Ooph, sorry - I reconfigured my IDEs auto-formatters recently. Fine for my project, not so much for others. Should be good now
There was a problem hiding this comment.
Ok, I have my act together now. test_env.py is now back to what it should be with just the added tests.
| assert Env.mailer_url_config(url) == { | ||
| 'BACKEND': 'django.core.mail.backends.smtp.EmailBackend', | ||
| 'OPTIONS': { | ||
| 'host': 'smtp.example.com', | ||
| 'timeout': 30, | ||
| 'use_ssl': 'false', | ||
| }, | ||
| } |
There was a problem hiding this comment.
I think instead of just testing against a fixed output, the tests would be more meaningful if you actually import the backend and initialize it. That way, we know the output configuration dictionary is correct.
There was a problem hiding this comment.
I gave it a tried importing the backend, and passing the options to initialise it, but it opened a bit of a can of worms.
The backend tried to access other Django settings - which failed because Django has not yet been bootrapped. And to bootstrap Django I need a settings file etc. So it gets a bit more complex than I think is worth it here.
I can continue down that rabbit hole if you would like me to, but I suspect the existing tests asserting against dicts might not be a coincidence.
There was a problem hiding this comment.
Ok, it also doesn't seem to be done on other parsers. While I believe it's a worthwhile improvement, its definitely exceeds the scope. Thanks for giving it a try though 👍
563a909 to
8ef1959
Compare
codingjoe
left a comment
There was a problem hiding this comment.
Hi @a-musing-moose,
please be so kind and review your own changes. You will have reformatting in your changeset.
I'd also recommend adding a deprecation warning for email_url for if Django >= 6.1. That way we can remove the parser once we sunset support for older Django versions.
Thanks for your patience, if you are quick I can do another review on FOSS Friday.
Best
-joe
03d2a25 to
46f5a52
Compare
I am terribly sorry for wasting your time on that round of reviews, and thanks for jumping on it so quickly. I have reviewer this one and with a little tweaking managed to get tox working locally. Side note: Installing The over-zealous reformatting should be gone now and we are back to just my changed. Which now includes a deprecation warning if |
46f5a52 to
d872a95
Compare
Provides a new mailer/mail_url which parses EMAIL URLs and returns configuration suitabler for the new Django 6.1 MAILERS setting. I've attempted to keep it fairly separate from the existing email URL parsing but to also make it easy to switch across to the new style options for example.
d872a95 to
b39fce9
Compare
Provides a new
mailer/mail_urlwhich parses EMAIL URLs and returns configuration suitable for the new Django 6.1 MAILERS setting.I've attempted to keep it fairly separate from the existing email URL parsing but to also make it easy to switch across to the new style options for example.
I am also not all the familiar with tox - but I have attempted to add Django 6.1 to the matrix, but may easily have messed something up.
tox -e py314-django61certainly runs cleanly locally. As do the others I have Python versions available for.Hopefully this is useful - but please let me know if I have missed anything important.
Resolves #606