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

Re-enable localisation of flash messages after migration to Flask 0.10+ #132

Closed
wants to merge 17 commits into from

Conversation

deanishe
Copy link
Contributor

Flask 0.10+ makes it impossible to use login_manager.login_message = lazy_gettext('Please log in') (no more pickle), thus buggering localisation of flask-login's flash messages.

Add a localize_callback attribute to LoginManager that, if present, will be called with login_message and needs_refresh_message and whose return value will be sent flash.

reith and others added 7 commits November 12, 2013 12:21
Add ability to override user id method name
Fire `user_loaded_from_cookie` even if token loader provided
Since Flask upgraded to 0.10, it's no longer possible to use
`lazy_gettext` to set `LoginManager.login_message`.

Add an optional `localization_function` argument/attribute to be called
with flash messages if the method is present.
Since Flask upgraded to 0.10, it's no longer possible to use
`lazy_gettext` to set `LoginManager.login_message`.

Add an optional `localizer` function as an argument/attribute to be
called on messages before they're "flashed".
Add shitty documentation of `localizer` argument/function.
@alanhamlett
Copy link
Collaborator

Looks like it needs tests.

Change to `localize_callback` attribute to match other callbacks.

Add corresponding tests to maintain 100% coverage.

Update documentation to reflect changes.
@deanishe
Copy link
Contributor Author

Passes all tests and has 100% test coverage now. No errors reported by pep8. Also changed the implementation to match other callbacks on LoginManager.

@@ -339,52 +349,52 @@ This documentation is automatically generated from Flask-Login's source code.
Configuring Login
-----------------
.. autoclass:: LoginManager

Copy link
Owner

Choose a reason for hiding this comment

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

Was this intentional?

@deanishe
Copy link
Contributor Author

Sorry, I don't quite understand the question. I'm not particularly familiar with Github and ReST. Did I delete an empty line?

@maxcountryman
Copy link
Owner

@deanishe it looks like lines were deleted from the documentation. I'm not sure if you meant to do that though?

@deanishe
Copy link
Contributor Author

My editor deleted trailing spaces. I don't believe I actually deleted any lines. Do the spaces need to be there for any reason (the docs compiled just dandy for me)?

@maxcountryman
Copy link
Owner

No it's fine if the spaces are removed I think. It just adds noise to commit is all.

@deanishe
Copy link
Contributor Author

Yeah, sorry about that. Can I compress all my changes/commits into one commit?

@maxcountryman
Copy link
Owner

Yes, please. And if you could rebase off master that would be great.

@deanishe
Copy link
Contributor Author

Err, that wasn't so much asking permission as asking how to … Afraid I also don't know what you mean by "rebase off master", though I'll do it if you could point me in the right direction.

@maxcountryman
Copy link
Owner

If you add this repo as a remote called upstream, then you can go ahead and do something like:

$ git pull --rebase upstream

Since Flask upgraded to 0.10, it's no longer possible to use
`lazy_gettext` to set `LoginManager.login_message`.

Add an optional `localization_function` argument/attribute to be called
with flash messages if the method is present.
Since Flask upgraded to 0.10, it's no longer possible to use
`lazy_gettext` to set `LoginManager.login_message`.

Add an optional `localizer` function as an argument/attribute to be
called on messages before they're "flashed".
Add shitty documentation of `localizer` argument/function.
Change to `localize_callback` attribute to match other callbacks.

Add corresponding tests to maintain 100% coverage.

Update documentation to reflect changes.
@deanishe
Copy link
Contributor Author

Rebased as requested (I think).

@deanishe deanishe closed this Dec 21, 2013
@maxcountryman
Copy link
Owner

Btw you can compress commits by using the "fixup" option in an interactive rebase.

$ git rebase -i HEAD~7

You should see a list of the commits with the word "pick" to the left of the commit. If you change "pick" to "f' for all by the commit you want to keep as the final commit, that should do what you want.

@deanishe
Copy link
Contributor Author

I think I've made a pig's ear of the commit log :( I'll re-fork and re-apply the edits.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants