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
9818664b
Commit
9818664b
authored
Jan 15, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storing work
parent
04614078
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
10 deletions
+37
-10
cms/djangoapps/contentstore/tests/test_core_caching.py
+18
-0
cms/djangoapps/contentstore/views.py
+1
-2
common/djangoapps/cache_toolbox/core.py
+15
-3
common/lib/xmodule/xmodule/contentstore/content.py
+2
-4
rakefile
+1
-1
No files found.
cms/djangoapps/contentstore/tests/test_core_caching.py
0 → 100644
View file @
9818664b
from
django.test.testcases
import
TestCase
from
cache_toolbox.core
import
get_cached_content
,
set_cached_content
import
mock
class
CachingTestCase
(
TestCase
):
# Tests for https://edx.lighthouseapp.com/projects/102637/tickets/112-updating-asset-does-not-refresh-the-cached-copy
def
test_put_and_get
(
self
):
mockAsset
=
mock
.
Mock
()
mockLocation
=
mock
.
Mock
()
mockLocation
.
category
=
u'thumbnail'
mockLocation
.
name
=
u'monsters.jpg'
mockLocation
.
course
=
u'800'
mockLocation
.
tag
=
u'c4x'
mockLocation
.
org
=
u'mitX'
mockLocation
.
revision
=
None
mockAsset
.
location
=
mockLocation
set_cached_content
(
mockAsset
)
cachedAsset
=
get_cached_content
(
mockLocation
)
cms/djangoapps/contentstore/views.py
View file @
9818664b
...
@@ -753,8 +753,7 @@ def upload_asset(request, org, course, coursename):
...
@@ -753,8 +753,7 @@ def upload_asset(request, org, course, coursename):
# nomenclature since we're using a FileSystem paradigm here. We're just imposing
# nomenclature since we're using a FileSystem paradigm here. We're just imposing
# the Location string formatting expectations to keep things a bit more consistent
# the Location string formatting expectations to keep things a bit more consistent
# unicode needed for cache equivalency
filename
=
request
.
FILES
[
'file'
]
.
name
filename
=
unicode
(
request
.
FILES
[
'file'
]
.
name
)
mime_type
=
request
.
FILES
[
'file'
]
.
content_type
mime_type
=
request
.
FILES
[
'file'
]
.
content_type
filedata
=
request
.
FILES
[
'file'
]
.
read
()
filedata
=
request
.
FILES
[
'file'
]
.
read
()
...
...
common/djangoapps/cache_toolbox/core.py
View file @
9818664b
...
@@ -108,11 +108,23 @@ def instance_key(model, instance_or_pk):
...
@@ -108,11 +108,23 @@ def instance_key(model, instance_or_pk):
getattr
(
instance_or_pk
,
'pk'
,
instance_or_pk
),
getattr
(
instance_or_pk
,
'pk'
,
instance_or_pk
),
)
)
import
logging
def
set_cached_content
(
content
):
def
set_cached_content
(
content
):
cache
.
set
(
content
.
get_id
(),
content
)
logging
.
warn
(
"set cached---------------------------------------"
)
logging
.
warn
(
str
(
content
.
location
))
cache
.
set
(
str
(
content
.
location
),
content
)
def
get_cached_content
(
location
):
def
get_cached_content
(
location
):
return
cache
.
get
(
StaticContent
.
get_id_from_location
(
location
))
logging
.
warn
(
"get cached------------------------"
)
logging
.
warn
(
str
(
location
))
logging
.
warn
(
StaticContent
.
get_id_from_location
(
location
))
return
cache
.
get
(
str
(
location
))
def
del_cached_content
(
location
):
def
del_cached_content
(
location
):
cache
.
delete
(
StaticContent
.
get_id_from_location
(
location
))
if
cache
.
get
(
str
(
location
))
is
None
:
logging
.
err
(
'nothing in cache for: '
+
str
(
location
))
logging
.
warn
(
"deleted cache----------"
)
logging
.
warn
(
str
(
location
))
logging
.
warn
(
StaticContent
.
get_id_from_location
(
location
))
cache
.
delete
(
str
(
location
))
common/lib/xmodule/xmodule/contentstore/content.py
View file @
9818664b
...
@@ -29,14 +29,12 @@ class StaticContent(object):
...
@@ -29,14 +29,12 @@ class StaticContent(object):
@staticmethod
@staticmethod
def
generate_thumbnail_name
(
original_name
):
def
generate_thumbnail_name
(
original_name
):
# unicode needed for cache equivalency
return
(
'{0}'
+
XASSET_THUMBNAIL_TAIL_NAME
)
.
format
(
os
.
path
.
splitext
(
original_name
)[
0
])
return
unicode
((
'{0}'
+
XASSET_THUMBNAIL_TAIL_NAME
)
.
format
(
os
.
path
.
splitext
(
original_name
)[
0
]))
@staticmethod
@staticmethod
def
compute_location
(
org
,
course
,
name
,
revision
=
None
,
is_thumbnail
=
False
):
def
compute_location
(
org
,
course
,
name
,
revision
=
None
,
is_thumbnail
=
False
):
name
=
name
.
replace
(
'/'
,
'_'
)
name
=
name
.
replace
(
'/'
,
'_'
)
# unicode needed for cache equivalency
return
Location
([
XASSET_LOCATION_TAG
,
org
,
course
,
'asset'
if
not
is_thumbnail
else
'thumbnail'
,
Location
.
clean
(
name
),
revision
])
return
Location
([
unicode
(
XASSET_LOCATION_TAG
),
org
,
course
,
u'asset'
if
not
is_thumbnail
else
u'thumbnail'
,
Location
.
clean
(
name
),
revision
])
def
get_id
(
self
):
def
get_id
(
self
):
return
StaticContent
.
get_id_from_location
(
self
.
location
)
return
StaticContent
.
get_id_from_location
(
self
.
location
)
...
...
rakefile
View file @
9818664b
...
@@ -120,7 +120,7 @@ default_options = {
...
@@ -120,7 +120,7 @@ default_options = {
}
}
task
:predjango
do
task
:predjango
do
sh
(
"find . -type f -name
*.pyc
-delete"
)
sh
(
"find . -type f -name
'*.pyc'
-delete"
)
sh
(
'pip install -q --upgrade --no-deps -r local-requirements.txt'
)
sh
(
'pip install -q --upgrade --no-deps -r local-requirements.txt'
)
end
end
...
...
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