Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
6a003988
Commit
6a003988
authored
Sep 18, 2015
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache keys should be unicode.
parent
f76efd8c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
openassessment/fileupload/backends/filesystem.py
+7
-6
openassessment/fileupload/views_filesystem.py
+2
-0
No files found.
openassessment/fileupload/backends/filesystem.py
View file @
6a003988
...
@@ -5,6 +5,7 @@ from .. import exceptions
...
@@ -5,6 +5,7 @@ from .. import exceptions
from
django.conf
import
settings
from
django.conf
import
settings
import
django.core.cache
import
django.core.cache
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.utils.encoding
import
smart_text
class
Backend
(
BaseBackend
):
class
Backend
(
BaseBackend
):
...
@@ -71,8 +72,8 @@ def make_upload_url_available(url_key_name, timeout):
...
@@ -71,8 +72,8 @@ def make_upload_url_available(url_key_name, timeout):
url_key_name (str): key that uniquely identifies the upload url
url_key_name (str): key that uniquely identifies the upload url
timeout (int): time in seconds before the url expires
timeout (int): time in seconds before the url expires
"""
"""
return
get_cache
()
.
set
(
get_cache
()
.
set
(
get_upload_cache_key
(
url_key_name
),
smart_text
(
get_upload_cache_key
(
url_key_name
)
),
1
,
timeout
1
,
timeout
)
)
...
@@ -84,8 +85,8 @@ def make_download_url_available(url_key_name, timeout):
...
@@ -84,8 +85,8 @@ def make_download_url_available(url_key_name, timeout):
url_key_name (str): key that uniquely identifies the url
url_key_name (str): key that uniquely identifies the url
timeout (int): time in seconds before the url expires
timeout (int): time in seconds before the url expires
"""
"""
return
get_cache
()
.
set
(
get_cache
()
.
set
(
get_download_cache_key
(
url_key_name
),
smart_text
(
get_download_cache_key
(
url_key_name
)
),
1
,
timeout
1
,
timeout
)
)
...
@@ -93,13 +94,13 @@ def is_upload_url_available(url_key_name):
...
@@ -93,13 +94,13 @@ def is_upload_url_available(url_key_name):
"""
"""
Return True if the corresponding upload URL is available.
Return True if the corresponding upload URL is available.
"""
"""
return
get_cache
()
.
get
(
get_upload_cache_key
(
url_key_name
))
is
not
None
return
get_cache
()
.
get
(
smart_text
(
get_upload_cache_key
(
url_key_name
)
))
is
not
None
def
is_download_url_available
(
url_key_name
):
def
is_download_url_available
(
url_key_name
):
"""
"""
Return True if the corresponding download URL is available.
Return True if the corresponding download URL is available.
"""
"""
return
get_cache
()
.
get
(
get_download_cache_key
(
url_key_name
))
is
not
None
return
get_cache
()
.
get
(
smart_text
(
get_download_cache_key
(
url_key_name
)
))
is
not
None
def
get_upload_cache_key
(
url_key_name
):
def
get_upload_cache_key
(
url_key_name
):
return
"upload/"
+
url_key_name
return
"upload/"
+
url_key_name
...
...
openassessment/fileupload/views_filesystem.py
View file @
6a003988
...
@@ -17,6 +17,8 @@ def filesystem_storage(request, key):
...
@@ -17,6 +17,8 @@ def filesystem_storage(request, key):
"""
"""
Uploading and download files to the local filesystem backend.
Uploading and download files to the local filesystem backend.
"""
"""
if
isinstance
(
key
,
unicode
):
key
=
key
.
encode
(
"utf-8"
)
if
request
.
method
==
"PUT"
:
if
request
.
method
==
"PUT"
:
if
not
is_upload_url_available
(
key
):
if
not
is_upload_url_available
(
key
):
raise
Http404
()
raise
Http404
()
...
...
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