Skip to content
This repository was archived by the owner on Oct 6, 2020. It is now read-only.

Commit 2d12b53

Browse files
committed
Py3, django 1.7 for example app, wheel support, tox
1 parent 92a59ff commit 2d12b53

File tree

13 files changed

+63
-42
lines changed

13 files changed

+63
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/lib
1010
/build
1111
.Python
12+
.tox

examples/protected_downloads/download/tests.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/protected_downloads/example/__init__.py

Whitespace-only changes.

examples/protected_downloads/settings.py renamed to examples/protected_downloads/example/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
'django.contrib.auth.middleware.AuthenticationMiddleware',
6868
)
6969

70-
ROOT_URLCONF = 'protected_downloads.urls'
70+
ROOT_URLCONF = 'example.urls'
7171

7272
TEMPLATE_DIRS = (
7373
os.path.join(PROJECT_ROOT, 'templates'),
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#!/usr/bin/env python
2+
import os
3+
import sys
24

3-
from __future__ import absolute_import
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
47

5-
from django.core.management import execute_manager
6-
try:
7-
from . import settings # Assumed to be in the same directory.
8-
except ImportError:
9-
import sys
10-
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
11-
sys.exit(1)
8+
from django.core.management import execute_from_command_line
129

13-
if __name__ == "__main__":
14-
execute_manager(settings)
10+
execute_from_command_line(sys.argv)

examples/protected_downloads/sendfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

sendfile/backends/_internalredirect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
from django.conf import settings
24
from django.utils.http import urlquote
35
import os.path
@@ -12,4 +14,4 @@ def _convert_file_to_url(filename):
1214
relpath, head = os.path.split(relpath)
1315
url.insert(1, head)
1416

15-
return urlquote(u'/'.join(url))
17+
return urlquote('/'.join(url))

sendfile/backends/xsendfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
def sendfile(request, filename, **kwargs):
66
response = HttpResponse()
7-
response['X-Sendfile'] = smart_str(unicode(filename))
7+
response['X-Sendfile'] = smart_str(filename)
88

99
return response

sendfile/tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# coding=utf-8
22

3+
from __future__ import unicode_literals
4+
35
from django.conf import settings
46
from django.test import TestCase
57
from django.http import HttpResponse, Http404, HttpRequest
@@ -102,7 +104,7 @@ def test_correct_file_in_xsendfile_header(self):
102104
self.assertEqual(filepath, response['X-Sendfile'])
103105

104106
def test_xsendfile_header_containing_unicode(self):
105-
filepath = self.ensure_file(u'péter_là_gueule.txt')
107+
filepath = self.ensure_file('péter_là_gueule.txt')
106108
response = real_sendfile(HttpRequest(), filepath)
107109
self.assertTrue(response is not None)
108110
self.assertEqual(smart_str(filepath), response['X-Sendfile'])
@@ -124,7 +126,7 @@ def test_correct_url_in_xaccelredirect_header(self):
124126
self.assertEqual('/private/readme.txt', response['X-Accel-Redirect'])
125127

126128
def test_xaccelredirect_header_containing_unicode(self):
127-
filepath = self.ensure_file(u'péter_là_gueule.txt')
129+
filepath = self.ensure_file('péter_là_gueule.txt')
128130
response = real_sendfile(HttpRequest(), filepath)
129131
self.assertTrue(response is not None)
130132
self.assertEqual('/private/p%C3%A9ter_l%C3%A0_gueule.txt', response['X-Accel-Redirect'])

0 commit comments

Comments
 (0)