Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
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
OpenEdx
django-wiki
Commits
5ff6fac9
Commit
5ff6fac9
authored
Jul 16, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #160 by allowing django-sendfile to be plugged in through settings.USE_SENDFILE
parent
04186424
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletions
+37
-1
testproject/testproject/settings/sendfile.py
+23
-0
wiki/conf/settings.py
+2
-0
wiki/core/http.py
+12
-1
No files found.
testproject/testproject/settings/sendfile.py
0 → 100644
View file @
5ff6fac9
from
testproject.settings
import
*
from
testproject.settings.local
import
*
#Django Haystack
INSTALLED_APPS
+=
[
'sendfile'
]
WIKI_ATTACHMENTS_USE_SENDFILE
=
True
SENDFILE_BACKEND
=
'sendfile.backends.development'
#SENDFILE_URL = '/protected'
# Whoosh backend is completely broken
# https://github.com/toastdriven/django-haystack/issues/522
# https://github.com/toastdriven/django-haystack/issues/382
# https://github.com/toastdriven/django-haystack/issues/447
#HAYSTACK_CONNECTIONS = {
# 'default': {
# 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
# 'PATH': os.path.join(PROJECT_PATH, 'whoosh_index'),
# },
#}
wiki/conf/settings.py
View file @
5ff6fac9
...
...
@@ -158,6 +158,8 @@ REVISIONS_MINUTES_LOOKBACK = getattr( django_settings, 'WIKI_REVISIONS_MINUTES_L
from
django.core.files.storage
import
default_storage
STORAGE_BACKEND
=
getattr
(
django_settings
,
'WIKI_STORAGE_BACKEND'
,
default_storage
)
USE_SENDFILE
=
getattr
(
django_settings
,
'WIKI_ATTACHMENTS_USE_SENDFILE'
,
False
)
####################
# PLANNED SETTINGS #
####################
...
...
wiki/core/http.py
View file @
5ff6fac9
...
...
@@ -6,6 +6,13 @@ from django.http import HttpResponse
from
django.utils.http
import
http_date
from
django.utils
import
dateformat
from
wiki.conf
import
settings
def
django_sendfile_response
(
request
,
filepath
):
from
sendfile
import
sendfile
return
sendfile
(
request
,
filepath
)
def
send_file
(
request
,
filepath
,
last_modified
=
None
,
filename
=
None
):
fullpath
=
filepath
# Respect the If-Modified-Since header.
...
...
@@ -16,7 +23,11 @@ def send_file(request, filepath, last_modified=None, filename=None):
mimetype
,
encoding
=
mimetypes
.
guess_type
(
fullpath
)
mimetype
=
mimetype
or
'application/octet-stream'
response
=
HttpResponse
(
open
(
fullpath
,
'rb'
)
.
read
(),
mimetype
=
mimetype
)
if
settings
.
USE_SENDFILE
:
response
=
django_sendfile_response
(
request
,
filepath
)
else
:
response
=
HttpResponse
(
open
(
fullpath
,
'rb'
)
.
read
(),
mimetype
=
mimetype
)
if
not
last_modified
:
response
[
"Last-Modified"
]
=
http_date
(
statobj
.
st_mtime
)
...
...
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