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

Fix flask_security celery tasks context - fix #1247 #1249

Merged
merged 1 commit into from Nov 6, 2017

Conversation

abulte
Copy link
Contributor

@abulte abulte commented Oct 30, 2017

patch_flask_security import need to be done after tasks.init_app so that the Celery configuration is taken into account.

#1247 was caused by the config task_serializer being json by default in Celery 4 and our own configuration (set to pickle) not taken into account on flask-security tasks.

@abulte abulte changed the title [WIP] Fix flask_security celery tasks context #1247 [WIP] Fix flask_security celery tasks context - fix #1247 Oct 30, 2017
@abulte
Copy link
Contributor Author

abulte commented Oct 30, 2017

NB: it would be even better to use this https://github.com/mattupstate/flask-security/blob/68a556c38c1e247394112774f03e59c96943f5b6/docs/customizing.rst#emails-with-celery instead of patching send_mail but there are other stuff (apart from sending emails delayed) we do in the patched method that I can not see how to reproduce without a patch: theme and i18n logic for template rendering.

@abulte abulte changed the title [WIP] Fix flask_security celery tasks context - fix #1247 Fix flask_security celery tasks context - fix #1247 Oct 30, 2017
@abulte abulte requested a review from a team October 30, 2017 12:29
@abulte
Copy link
Contributor Author

abulte commented Oct 30, 2017

About above NB: maybe submit a PR to flask-security with a new hook that would let us define our own way of building the Message object to be sent. This way we could use this new hook and the send_mail_task one and remove the patch.

@abulte abulte merged commit bd41f77 into opendatateam:master Nov 6, 2017
@abulte abulte removed the in progress label Nov 6, 2017
@abulte abulte deleted the gh-1247-signup-error branch November 6, 2017 09:14
@noirbizarre
Copy link
Contributor

+1 for the upstream PR to support a custom send_mail_task.
Half of the job is done because now flask-security already use the custom render method in mails too: pallets-eco/flask-security#487

@abulte
Copy link
Contributor Author

abulte commented Nov 6, 2017

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.

None yet

2 participants