diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | buildout.cfg | 2 | ||||
-rw-r--r-- | chishop/conf/__init__.py | 0 | ||||
-rw-r--r-- | chishop/conf/default.py | 111 | ||||
-rw-r--r-- | chishop/development.py | 23 | ||||
-rw-r--r-- | chishop/production_example.py | 18 | ||||
-rw-r--r-- | chishop/settings.py | 112 | ||||
-rw-r--r-- | chishop/urls.py | 2 | ||||
-rw-r--r-- | djangopypi/tests.py | 3 | ||||
-rw-r--r-- | djangopypi/views.py | 2 |
11 files changed, 153 insertions, 128 deletions
@@ -5,3 +5,4 @@ Brian Rosner <brosner@gmail.com> | |||
5 | Hugo Lopes Tavares <hltbra@gmail.com> | 5 | Hugo Lopes Tavares <hltbra@gmail.com> |
6 | Sverre Johansen <sverre.johansen@gmail.com> | 6 | Sverre Johansen <sverre.johansen@gmail.com> |
7 | Bo Shi <bs@alum.mit.edu> | 7 | Bo Shi <bs@alum.mit.edu> |
8 | Carl Meyer <carl@dirtcircle.com> | ||
@@ -27,6 +27,13 @@ Run the PyPI server | |||
27 | Please note that ``chishop/media/dists`` has to be writable by the | 27 | Please note that ``chishop/media/dists`` has to be writable by the |
28 | user the web-server is running as. | 28 | user the web-server is running as. |
29 | 29 | ||
30 | In production | ||
31 | ------------- | ||
32 | |||
33 | You may want to copy the file ``chishop/production_example.py`` and modify | ||
34 | for use as your production settings; you will also need to modify | ||
35 | ``bin/django.wsgi`` to refer to your production settings. | ||
36 | |||
30 | Using Setuptools | 37 | Using Setuptools |
31 | ================ | 38 | ================ |
32 | 39 | ||
diff --git a/buildout.cfg b/buildout.cfg index 04e0acf..160db4c 100644 --- a/buildout.cfg +++ b/buildout.cfg | |||
@@ -8,7 +8,7 @@ eggs = pkginfo | |||
8 | [django] | 8 | [django] |
9 | recipe = djangorecipe | 9 | recipe = djangorecipe |
10 | version = 1.1.1 | 10 | version = 1.1.1 |
11 | settings = development | 11 | settings = settings |
12 | eggs = ${buildout:eggs} | 12 | eggs = ${buildout:eggs} |
13 | test = djangopypi | 13 | test = djangopypi |
14 | project = chishop | 14 | project = chishop |
diff --git a/chishop/conf/__init__.py b/chishop/conf/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/chishop/conf/__init__.py | |||
diff --git a/chishop/conf/default.py b/chishop/conf/default.py new file mode 100644 index 0000000..97002b6 --- /dev/null +++ b/chishop/conf/default.py | |||
@@ -0,0 +1,111 @@ | |||
1 | # Django settings for djangopypi project. | ||
2 | import os | ||
3 | |||
4 | ADMINS = ( | ||
5 | # ('Your Name', 'your_email@domain.com'), | ||
6 | ) | ||
7 | |||
8 | # Allow uploading a new distribution file for a project version | ||
9 | # if a file of that type already exists. | ||
10 | # | ||
11 | # The default on PyPI is to not allow this, but it can be real handy | ||
12 | # if you're sloppy. | ||
13 | DJANGOPYPI_ALLOW_VERSION_OVERWRITE = False | ||
14 | DJANGOPYPI_RELEASE_UPLOAD_TO = 'dists' | ||
15 | |||
16 | # change to False if you do not want Django's default server to serve static pages | ||
17 | LOCAL_DEVELOPMENT = True | ||
18 | |||
19 | REGISTRATION_OPEN = True | ||
20 | ACCOUNT_ACTIVATION_DAYS = 7 | ||
21 | LOGIN_REDIRECT_URL = "/" | ||
22 | |||
23 | EMAIL_HOST = '' | ||
24 | DEFAULT_FROM_EMAIL = '' | ||
25 | SERVER_EMAIL = DEFAULT_FROM_EMAIL | ||
26 | |||
27 | MANAGERS = ADMINS | ||
28 | |||
29 | DATABASE_ENGINE = '' | ||
30 | DATABASE_NAME = '' | ||
31 | DATABASE_USER = '' | ||
32 | DATABASE_PASSWORD = '' | ||
33 | DATABASE_HOST = '' | ||
34 | DATABASE_PORT = '' | ||
35 | |||
36 | # Local time zone for this installation. Choices can be found here: | ||
37 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
38 | # although not all choices may be available on all operating systems. | ||
39 | # If running in a Windows environment this must be set to the same as your | ||
40 | # system time zone. | ||
41 | TIME_ZONE = 'America/Chicago' | ||
42 | |||
43 | # Language code for this installation. All choices can be found here: | ||
44 | # http://www.i18nguy.com/unicode/language-identifiers.html | ||
45 | LANGUAGE_CODE = 'en-us' | ||
46 | |||
47 | SITE_ID = 1 | ||
48 | |||
49 | # If you set this to False, Django will make some optimizations so as not | ||
50 | # to load the internationalization machinery. | ||
51 | USE_I18N = True | ||
52 | |||
53 | # Absolute path to the directory that holds media. | ||
54 | # Example: "/home/media/media.lawrence.com/" | ||
55 | here = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) | ||
56 | MEDIA_ROOT = os.path.join(here, 'media') | ||
57 | |||
58 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a | ||
59 | # trailing slash if there is a path component (optional in other cases). | ||
60 | # Examples: "http://media.lawrence.com", "http://example.com/media/" | ||
61 | MEDIA_URL = '/media/' | ||
62 | |||
63 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a | ||
64 | # trailing slash. | ||
65 | # Examples: "http://foo.com/media/", "/media/". | ||
66 | ADMIN_MEDIA_PREFIX = '/admin-media/' | ||
67 | |||
68 | # Make this unique, and don't share it with anybody. | ||
69 | SECRET_KEY = 'w_#0r2hh)=!zbynb*gg&969@)sy#^-^ia3m*+sd4@lst$zyaxu' | ||
70 | |||
71 | # List of callables that know how to import templates from various sources. | ||
72 | TEMPLATE_LOADERS = ( | ||
73 | 'django.template.loaders.filesystem.load_template_source', | ||
74 | 'django.template.loaders.app_directories.load_template_source', | ||
75 | # 'django.template.loaders.eggs.load_template_source', | ||
76 | ) | ||
77 | |||
78 | MIDDLEWARE_CLASSES = ( | ||
79 | 'django.middleware.common.CommonMiddleware', | ||
80 | 'django.contrib.sessions.middleware.SessionMiddleware', | ||
81 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
82 | ) | ||
83 | |||
84 | ROOT_URLCONF = 'urls' | ||
85 | |||
86 | TEMPLATE_CONTEXT_PROCESSORS = ( | ||
87 | "django.core.context_processors.auth", | ||
88 | "django.core.context_processors.debug", | ||
89 | "django.core.context_processors.i18n", | ||
90 | "django.core.context_processors.media", | ||
91 | "django.core.context_processors.request", | ||
92 | ) | ||
93 | |||
94 | TEMPLATE_DIRS = ( | ||
95 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
96 | # Always use forward slashes, even on Windows. | ||
97 | # Don't forget to use absolute paths, not relative paths. | ||
98 | os.path.join(os.path.dirname(os.path.dirname(__file__)), "templates"), | ||
99 | ) | ||
100 | |||
101 | INSTALLED_APPS = ( | ||
102 | 'django.contrib.auth', | ||
103 | 'django.contrib.contenttypes', | ||
104 | 'django.contrib.sessions', | ||
105 | 'django.contrib.sites', | ||
106 | 'django.contrib.admin', | ||
107 | 'django.contrib.markup', | ||
108 | 'django.contrib.admindocs', | ||
109 | 'registration', | ||
110 | 'djangopypi', | ||
111 | ) | ||
diff --git a/chishop/development.py b/chishop/development.py deleted file mode 100644 index 0671fc2..0000000 --- a/chishop/development.py +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | from settings import * | ||
2 | import os | ||
3 | |||
4 | DEBUG = True | ||
5 | TEMPLATE_DEBUG = DEBUG | ||
6 | LOCAL_DEVELOPMENT = True | ||
7 | |||
8 | if LOCAL_DEVELOPMENT: | ||
9 | import sys | ||
10 | sys.path.append(os.path.dirname(__file__)) | ||
11 | |||
12 | ADMINS = ( | ||
13 | ('chishop', 'example@example.org'), | ||
14 | ) | ||
15 | |||
16 | MANAGERS = ADMINS | ||
17 | |||
18 | DATABASE_ENGINE = 'sqlite3' | ||
19 | DATABASE_NAME = os.path.join(here, 'devdatabase.db') | ||
20 | DATABASE_USER = '' | ||
21 | DATABASE_PASSWORD = '' | ||
22 | DATABASE_HOST = '' | ||
23 | DATABASE_PORT = '' | ||
diff --git a/chishop/production_example.py b/chishop/production_example.py new file mode 100644 index 0000000..b64623e --- /dev/null +++ b/chishop/production_example.py | |||
@@ -0,0 +1,18 @@ | |||
1 | from conf.default import * | ||
2 | import os | ||
3 | |||
4 | DEBUG = False | ||
5 | TEMPLATE_DEBUG = DEBUG | ||
6 | |||
7 | ADMINS = ( | ||
8 | ('chishop', 'example@example.org'), | ||
9 | ) | ||
10 | |||
11 | MANAGERS = ADMINS | ||
12 | |||
13 | DATABASE_ENGINE = 'postgresql_psycopg2' | ||
14 | DATABASE_NAME = 'chishop' | ||
15 | DATABASE_USER = 'chishop' | ||
16 | DATABASE_PASSWORD = 'chishop' | ||
17 | DATABASE_HOST = '' | ||
18 | DATABASE_PORT = '' | ||
diff --git a/chishop/settings.py b/chishop/settings.py index ee286b5..e68a4e5 100644 --- a/chishop/settings.py +++ b/chishop/settings.py | |||
@@ -1,113 +1,23 @@ | |||
1 | # Django settings for djangopypi project. | 1 | from conf.default import * |
2 | import os | 2 | import os |
3 | 3 | ||
4 | ADMINS = ( | 4 | DEBUG = True |
5 | # ('Your Name', 'your_email@domain.com'), | 5 | TEMPLATE_DEBUG = DEBUG |
6 | ) | ||
7 | |||
8 | # Allow uploading a new distribution file for a project version | ||
9 | # if a file of that type already exists. | ||
10 | # | ||
11 | # The default on PyPI is to not allow this, but it can be real handy | ||
12 | # if you're sloppy. | ||
13 | DJANGOPYPI_ALLOW_VERSION_OVERWRITE = False | ||
14 | DJANGOPYPI_RELEASE_UPLOAD_TO = 'dists' | ||
15 | |||
16 | # change to False if you do not want Django's default server to serve static pages | ||
17 | LOCAL_DEVELOPMENT = True | 6 | LOCAL_DEVELOPMENT = True |
18 | 7 | ||
19 | REGISTRATION_OPEN = True | 8 | if LOCAL_DEVELOPMENT: |
20 | ACCOUNT_ACTIVATION_DAYS = 7 | 9 | import sys |
21 | LOGIN_REDIRECT_URL = "/" | 10 | sys.path.append(os.path.dirname(__file__)) |
22 | 11 | ||
23 | EMAIL_HOST = '' | 12 | ADMINS = ( |
24 | DEFAULT_FROM_EMAIL = '' | 13 | ('chishop', 'example@example.org'), |
25 | SERVER_EMAIL = DEFAULT_FROM_EMAIL | 14 | ) |
26 | 15 | ||
27 | MANAGERS = ADMINS | 16 | MANAGERS = ADMINS |
28 | 17 | ||
29 | DATABASE_ENGINE = '' | 18 | DATABASE_ENGINE = 'sqlite3' |
30 | DATABASE_NAME = '' | 19 | DATABASE_NAME = os.path.join(here, 'devdatabase.db') |
31 | DATABASE_USER = '' | 20 | DATABASE_USER = '' |
32 | DATABASE_PASSWORD = '' | 21 | DATABASE_PASSWORD = '' |
33 | DATABASE_HOST = '' | 22 | DATABASE_HOST = '' |
34 | DATABASE_PORT = '' | 23 | DATABASE_PORT = '' |
35 | |||
36 | # Local time zone for this installation. Choices can be found here: | ||
37 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
38 | # although not all choices may be available on all operating systems. | ||
39 | # If running in a Windows environment this must be set to the same as your | ||
40 | # system time zone. | ||
41 | TIME_ZONE = 'America/Chicago' | ||
42 | |||
43 | # Language code for this installation. All choices can be found here: | ||
44 | # http://www.i18nguy.com/unicode/language-identifiers.html | ||
45 | LANGUAGE_CODE = 'en-us' | ||
46 | |||
47 | SITE_ID = 1 | ||
48 | |||
49 | # If you set this to False, Django will make some optimizations so as not | ||
50 | # to load the internationalization machinery. | ||
51 | USE_I18N = True | ||
52 | |||
53 | # Absolute path to the directory that holds media. | ||
54 | # Example: "/home/media/media.lawrence.com/" | ||
55 | here = os.path.abspath(os.path.dirname(__file__)) | ||
56 | MEDIA_ROOT = os.path.join(here, 'media') | ||
57 | |||
58 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a | ||
59 | # trailing slash if there is a path component (optional in other cases). | ||
60 | # Examples: "http://media.lawrence.com", "http://example.com/media/" | ||
61 | MEDIA_URL = 'media/' | ||
62 | |||
63 | MEDIA_PREFIX = "/media/" | ||
64 | |||
65 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a | ||
66 | # trailing slash. | ||
67 | # Examples: "http://foo.com/media/", "/media/". | ||
68 | ADMIN_MEDIA_PREFIX = '/admin-media/' | ||
69 | |||
70 | # Make this unique, and don't share it with anybody. | ||
71 | SECRET_KEY = 'w_#0r2hh)=!zbynb*gg&969@)sy#^-^ia3m*+sd4@lst$zyaxu' | ||
72 | |||
73 | # List of callables that know how to import templates from various sources. | ||
74 | TEMPLATE_LOADERS = ( | ||
75 | 'django.template.loaders.filesystem.load_template_source', | ||
76 | 'django.template.loaders.app_directories.load_template_source', | ||
77 | # 'django.template.loaders.eggs.load_template_source', | ||
78 | ) | ||
79 | |||
80 | MIDDLEWARE_CLASSES = ( | ||
81 | 'django.middleware.common.CommonMiddleware', | ||
82 | 'django.contrib.sessions.middleware.SessionMiddleware', | ||
83 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
84 | ) | ||
85 | |||
86 | ROOT_URLCONF = 'urls' | ||
87 | |||
88 | TEMPLATE_CONTEXT_PROCESSORS = ( | ||
89 | "django.core.context_processors.auth", | ||
90 | "django.core.context_processors.debug", | ||
91 | "django.core.context_processors.i18n", | ||
92 | "django.core.context_processors.media", | ||
93 | "django.core.context_processors.request", | ||
94 | ) | ||
95 | |||
96 | TEMPLATE_DIRS = ( | ||
97 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
98 | # Always use forward slashes, even on Windows. | ||
99 | # Don't forget to use absolute paths, not relative paths. | ||
100 | os.path.join(os.path.dirname(__file__), "templates"), | ||
101 | ) | ||
102 | |||
103 | INSTALLED_APPS = ( | ||
104 | 'django.contrib.auth', | ||
105 | 'django.contrib.contenttypes', | ||
106 | 'django.contrib.sessions', | ||
107 | 'django.contrib.sites', | ||
108 | 'django.contrib.admin', | ||
109 | 'django.contrib.markup', | ||
110 | 'django.contrib.admindocs', | ||
111 | 'registration', | ||
112 | 'djangopypi', | ||
113 | ) | ||
diff --git a/chishop/urls.py b/chishop/urls.py index ab2e8a9..5a5dd77 100644 --- a/chishop/urls.py +++ b/chishop/urls.py | |||
@@ -10,7 +10,7 @@ urlpatterns = patterns('') | |||
10 | # Serve static pages. | 10 | # Serve static pages. |
11 | if settings.LOCAL_DEVELOPMENT: | 11 | if settings.LOCAL_DEVELOPMENT: |
12 | urlpatterns += patterns("django.views", | 12 | urlpatterns += patterns("django.views", |
13 | url(r"%s(?P<path>.*)$" % settings.MEDIA_URL[1:], "static.serve", { | 13 | url(r"^%s(?P<path>.*)$" % settings.MEDIA_URL[1:], "static.serve", { |
14 | "document_root": settings.MEDIA_ROOT})) | 14 | "document_root": settings.MEDIA_ROOT})) |
15 | 15 | ||
16 | urlpatterns += patterns("", | 16 | urlpatterns += patterns("", |
diff --git a/djangopypi/tests.py b/djangopypi/tests.py index 4da4122..44ec3ac 100644 --- a/djangopypi/tests.py +++ b/djangopypi/tests.py | |||
@@ -84,12 +84,13 @@ class TestParseWeirdPostData(unittest.TestCase): | |||
84 | data = create_post_data("submit") | 84 | data = create_post_data("submit") |
85 | raw_post_data = create_request(data) | 85 | raw_post_data = create_request(data) |
86 | post, files = parse_distutils_request(MockRequest(raw_post_data)) | 86 | post, files = parse_distutils_request(MockRequest(raw_post_data)) |
87 | print("post: %s files: %s" % (post, files)) | ||
88 | self.assertTrue(post) | 87 | self.assertTrue(post) |
89 | 88 | ||
90 | for key in post.keys(): | 89 | for key in post.keys(): |
91 | if isinstance(data[key], list): | 90 | if isinstance(data[key], list): |
92 | self.assertEquals(data[key], post.getlist(key)) | 91 | self.assertEquals(data[key], post.getlist(key)) |
92 | elif data[key] == "UNKNOWN": | ||
93 | self.assertTrue(post[key] is None) | ||
93 | else: | 94 | else: |
94 | self.assertEquals(post[key], data[key]) | 95 | self.assertEquals(post[key], data[key]) |
95 | 96 | ||
diff --git a/djangopypi/views.py b/djangopypi/views.py index 7e2d0dc..9c78fcf 100644 --- a/djangopypi/views.py +++ b/djangopypi/views.py | |||
@@ -217,7 +217,7 @@ def show_version(request, dist_name, version, | |||
217 | try: | 217 | try: |
218 | release = Project.objects.get(name=dist_name).releases \ | 218 | release = Project.objects.get(name=dist_name).releases \ |
219 | .get(version=version) | 219 | .get(version=version) |
220 | except Project.DoesNotExist: | 220 | except (Project.DoesNotExist, Release.DoesNotExist): |
221 | raise Http404() | 221 | raise Http404() |
222 | 222 | ||
223 | context = RequestContext(request, { | 223 | context = RequestContext(request, { |