Browse Source

run fcgi (not dotcloud), django 1.5

also, fix link on submit.html page
raylu 12 năm trước cách đây
mục cha
commit
9decbd2ffd
8 tập tin đã thay đổi với 13 bổ sung31 xóa
  1. 1 0
      .gitignore
  2. 0 2
      dotcloud.yml
  3. 0 2
      postinstall
  4. 3 9
      pyc/settings.py
  5. 5 5
      pyc/templates/base.html
  6. 1 1
      pyc/templates/submit.html
  7. 3 0
      run.sh
  8. 0 12
      wsgi.py

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 *.pyc
 pyc/pyc.db
 static/admin
+submissions/

+ 0 - 2
dotcloud.yml

@@ -1,2 +0,0 @@
-www:
-    type: python

+ 0 - 2
postinstall

@@ -1,7 +1,5 @@
 #!/usr/bin/env python
 
-# http://docs.dotcloud.com/tutorials/django/#static-files-and-admin-media
-
 import os
 os.environ['DJANGO_SETTINGS_MODULE'] = 'pyc.settings'
 import django.contrib.admin

+ 3 - 9
pyc/settings.py

@@ -1,4 +1,4 @@
-# Django settings for pyc project.
+from os import path
 
 DEBUG = True
 TEMPLATE_DEBUG = DEBUG
@@ -12,7 +12,7 @@ MANAGERS = ADMINS
 DATABASES = {
 	'default': {
 		'ENGINE': 'django.db.backends.sqlite3', # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3', 'oracle'
-		'NAME': None,
+		'NAME': path.join(path.dirname(__file__), 'pyc.db'),
 		'USER': '',
 		'PASSWORD': '',
 		'HOST': '',
@@ -20,12 +20,6 @@ DATABASES = {
 	}
 }
 
-from os import path
-if path.exists('/home/dotcloud'):
-	DATABASES['default']['NAME'] = '/home/dotcloud/pyc.db'
-else:
-	DATABASES['default']['NAME'] = 'pyc.db'
-
 # Local time zone for this installation. Choices can be found here:
 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
 # although not all choices may be available on all operating systems.
@@ -51,7 +45,7 @@ USE_L10N = True
 
 # Absolute filesystem path to the directory that will hold user-uploaded files.
 # Example: "/home/media/media.lawrence.com/media/"
-MEDIA_ROOT = path.expanduser('~/submissions')
+MEDIA_ROOT = path.join(path.dirname(__file__), '..', 'submissions')
 
 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
 # trailing slash.

+ 5 - 5
pyc/templates/base.html

@@ -15,7 +15,7 @@
 		{% load cache %}
 		{% cache 30 nav %}
 		<div class="nav">
-			<a href="{% url grader.views.index %}">Home</a>
+			<a href="{% url "grader.views.index" %}">Home</a>
 
 			<p>Labs:</p>
 			<ol>
@@ -24,16 +24,16 @@
 			{% endfor %}
 			</ol>
 
-			<a href="{% url grader.views.faq %}">FAQ</a>
+			<a href="{% url "grader.views.faq" %}">FAQ</a>
 		</div>
 		{% endcache %}
 		<div class="nav">
 			{% if authenticated %}
-				<a href="{% url django.contrib.auth.views.password_change %}">Change Password</a>
+				<a href="{% url "django.contrib.auth.views.password_change" %}">Change Password</a>
 				<br />
-				<a href="{% url django.contrib.auth.views.logout %}">Logout</a>
+				<a href="{% url "django.contrib.auth.views.logout" %}">Logout</a>
 			{% else %}
-				<a href="{% url django.contrib.auth.views.login %}">Login</a>
+				<a href="{% url "django.contrib.auth.views.login" %}">Login</a>
 			{% endif %}
 		</div>
 	</div>

+ 1 - 1
pyc/templates/submit.html

@@ -19,6 +19,6 @@
 </p>
 
 <p>
-<a href="/lab/{{ lab_id }}">Back</a> to rankings
+<a href="/lab/{{ lab_id }}/">Back</a> to rankings
 </p>
 {% endblock %}

+ 3 - 0
run.sh

@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+cd pyc
+sudo -u www-data PYTHONPATH=/var/www/pyc.raylu.net:/var/www/pyc.raylu.net/pyc:/var/www/pyc.raylu.net/submissions DJANGO_SETTINGS_MODULE=pyc.settings django-admin runfcgi socket=/var/run/lighttpd/wsgi.socket method=threaded

+ 0 - 12
wsgi.py

@@ -1,12 +0,0 @@
-import os, sys
-
-os.environ['DJANGO_SETTINGS_MODULE'] = 'pyc.settings'
-sys.path.append('/home/dotcloud/current/pyc')
-
-import django.core.handlers.wsgi
-djangoapplication = django.core.handlers.wsgi.WSGIHandler()
-
-def application(environ, start_response):
-	if 'SCRIPT_NAME' in environ:
-		del environ['SCRIPT_NAME']
-	return djangoapplication(environ, start_response)