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
193ca7b3
Commit
193ca7b3
authored
Oct 05, 2012
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error when creating empty associations
Also renamed some variables to make them more distinguishable
parent
e62968d5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
common/djangoapps/external_auth/djangostore.py
+19
-19
No files found.
common/djangoapps/external_auth/djangostore.py
View file @
193ca7b3
...
...
@@ -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
]
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
:
association
=
associations
.
get
(
handle
)
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