Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
7e304abe
Commit
7e304abe
authored
Oct 05, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #833 from MITx/feature/rocha/openid-djangostore
Fix error when creating empty associations
parents
82d3adc5
193ca7b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
22 deletions
+22
-22
common/djangoapps/external_auth/djangostore.py
+22
-22
No files found.
common/djangoapps/external_auth/djangostore.py
View file @
7e304abe
...
...
@@ -8,7 +8,7 @@ from django.core.cache import cache
import
logging
import
time
DEFAULT_ASSOCIATION_TIMEOUT
=
60
DEFAULT_ASSOCIATION
S
_TIMEOUT
=
60
DEFAULT_NONCE_TIMEOUT
=
600
ASSOCIATIONS_KEY_PREFIX
=
'openid.provider.associations.'
...
...
@@ -34,51 +34,51 @@ class DjangoOpenIDStore(OpenIDStore):
def
__init__
(
self
):
log
.
info
(
'DjangoStore cache:'
+
str
(
cache
.
__class__
))
def
storeAssociation
(
self
,
server_url
,
assoc
iation
):
def
storeAssociation
(
self
,
server_url
,
assoc
):
key
=
get_url_key
(
server_url
)
log
.
info
(
'storeAssociation {0}'
.
format
(
key
))
associations
=
cache
.
get
(
key
,
{})
associations
[
assoc
iation
.
handle
]
=
association
associations
[
assoc
.
handle
]
=
assoc
cache
.
set
(
key
,
associations
,
DEFAULT_ASSOCIATION_TIMEOUT
)
cache
.
set
(
key
,
associations
,
DEFAULT_ASSOCIATION
S
_TIMEOUT
)
def
getAssociation
(
self
,
server_url
,
handle
=
None
):
key
=
get_url_key
(
server_url
)
log
.
info
(
'getAssociation {0}'
.
format
(
key
))
associations
=
cache
.
get
(
key
)
associations
=
cache
.
get
(
key
,
{}
)
assoc
iation
=
None
assoc
=
None
if
associations
:
if
handle
is
None
:
# get best association
valid
=
[
a
for
a
in
associations
if
a
.
getExpiresIn
()
>
0
]
if
valid
:
association
=
valid
[
0
]
else
:
association
=
associations
.
get
(
handle
)
if
handle
is
None
:
# get best association
valid_assocs
=
[
a
for
a
in
associations
if
a
.
getExpiresIn
()
>
0
]
if
valid_assocs
:
valid_assocs
.
sort
(
lambda
a
:
a
.
getExpiresIn
(),
reverse
=
True
)
assoc
=
valid_assocs
.
sort
[
0
]
else
:
assoc
=
associations
.
get
(
handle
)
# check expiration and remove if it has expired
if
assoc
iation
and
association
.
getExpiresIn
()
<=
0
:
if
assoc
and
assoc
.
getExpiresIn
()
<=
0
:
if
handle
is
None
:
cache
.
delete
(
key
)
else
:
associations
.
pop
(
handle
)
cache
.
set
(
key
,
association
,
DEFAULT_ASSOCIATION
_TIMEOUT
)
assoc
iation
=
None
cache
.
set
(
key
,
association
s
,
DEFAULT_ASSOCIATIONS
_TIMEOUT
)
assoc
=
None
return
assoc
iation
return
assoc
def
removeAssociation
(
self
,
server_url
,
handle
):
key
=
get_url_key
(
server_url
)
log
.
info
(
'removeAssociation {0}'
.
format
(
key
))
associations
=
cache
.
get
(
key
)
associations
=
cache
.
get
(
key
,
{}
)
removed
=
False
...
...
@@ -87,9 +87,9 @@ class DjangoOpenIDStore(OpenIDStore):
cache
.
delete
(
key
)
removed
=
True
else
:
assoc
iation
=
associations
.
pop
(
handle
)
if
assoc
iation
:
cache
.
set
(
key
,
association
,
DEFAULT_ASSOCIATION
_TIMEOUT
)
assoc
=
associations
.
pop
(
handle
)
if
assoc
:
cache
.
set
(
key
,
association
s
,
DEFAULT_ASSOCIATIONS
_TIMEOUT
)
removed
=
True
return
removed
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment