Skip to content

Commit

Permalink
Port PR #1004 by tsouvarev
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Dec 4, 2016
1 parent 2b8e06a commit 78da4eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added Dockerfile to simplify the running of tests (`make docker-tox`)

### Changed
- Preserve order of backends in BACKENDSCACHE (port from [#1004](https://github.com/omab/python-social-auth/pull/1004)
by tsouvarev)
- Don't lose custom exception message on raising AuthCanceled (port from [#1062](https://github.com/omab/python-social-auth/pull/1062)
by dotsbb)
- Fixed VK backend (port from [#1007](https://github.com/omab/python-social-auth/pull/1007)
Expand Down
8 changes: 5 additions & 3 deletions social_core/backends/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from ..exceptions import MissingBackend
from collections import OrderedDict

from .base import BaseAuth
from ..exceptions import MissingBackend
from ..utils import module_member, user_is_authenticated


# Cache for discovered backends.
BACKENDSCACHE = {}
BACKENDSCACHE = OrderedDict()


def load_backends(backends, force_load=False):
Expand All @@ -27,7 +29,7 @@ def load_backends(backends, force_load=False):
"""
global BACKENDSCACHE
if force_load:
BACKENDSCACHE = {}
BACKENDSCACHE = OrderedDict()
if not BACKENDSCACHE:
for auth_backend in backends:
backend = module_member(auth_backend)
Expand Down
3 changes: 1 addition & 2 deletions social_core/tests/backends/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def test_load_backends(self):
'social_core.backends.flickr.FlickrOAuth'
), force_load=True)
keys = list(loaded_backends.keys())
keys.sort()
self.assertEqual(keys, ['facebook', 'flickr', 'github'])
self.assertEqual(keys, ['github', 'facebook', 'flickr'])

backends = ()
loaded_backends = load_backends(backends, force_load=True)
Expand Down

0 comments on commit 78da4eb

Please sign in to comment.