Permalink
Browse files

Fix to url pattern for index; add index.wsgi

  • Loading branch information...
1 parent 5d9a119 commit 7ca1f1fc7f2ef03375df23c70f86ed30d22ca825 @lmorchard lmorchard committed Oct 12, 2010
Showing with 44 additions and 1 deletion.
  1. +1 −1 apps/homesnippets/urls.py
  2. +43 −0 wsgi/index.wsgi
View
2 apps/homesnippets/urls.py
@@ -8,7 +8,7 @@
# browser/components/nsBrowserContentHandler.js:911: const SNIPPETS_URL = "http://snippets.mozilla.com/" + STARTPAGE_VERSION + "/%NAME%/%VERSION%/%APPBUILDID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/";
url(r'^(?P<STARTPAGE_VERSION>[^/]+)/(?P<NAME>[^/]+)/(?P<VERSION>[^/]+)/(?P<APPBUILDID>[^/]+)/(?P<BUILD_TARGET>[^/]+)/(?P<LOCALE>[^/]+)/(?P<CHANNEL>[^/]+)/(?P<OS_VERSION>[^/]+)/(?P<DISTRIBUTION>[^/]+)/(?P<DISTRIBUTION_VERSION>[^/]+)/$',
- 'view_snippet', name='view_snippets'),
+ 'view_snippets', name='view_snippets'),
url(r"^$", "index", name="index"),
)
View
43 wsgi/index.wsgi
@@ -0,0 +1,43 @@
+import os
+import site
+import sys
+from datetime import datetime
+
+# fix markdown.py (and potentially others) using stdout
+sys.stdout = sys.stderr
+
+# Remember when mod_wsgi loaded this file so we can track it in nagios.
+wsgi_loaded = datetime.now()
+
+# Add the main dir to the python path so we can import manage.
+wsgidir = os.path.dirname(__file__)
+site.addsitedir(os.path.abspath(os.path.join(wsgidir, '../')))
+
+# manage adds /apps, /lib, and /vendor to the Python path.
+import manage
+
+import django.conf
+import django.core.handlers.wsgi
+import django.core.management
+import django.utils
+
+# Do validate and activate translations like using `./manage.py runserver`.
+# http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
+utility = django.core.management.ManagementUtility()
+command = utility.fetch_command('runserver')
+command.validate()
+
+# This is what mod_wsgi runs.
+django_app = django.core.handlers.wsgi.WSGIHandler()
+
+def application(env, start_response):
+ env['wsgi.loaded'] = wsgi_loaded
+ return django_app(env, start_response)
+
+# Uncomment this to figure out what's going on with the mod_wsgi environment.
+# def application(env, start_response):
+# start_response('200 OK', [('Content-Type', 'text/plain')])
+# return '\n'.join('%r: %r' % item for item in sorted(env.items()))
+
+# vim: ft=python
+

0 comments on commit 7ca1f1f

Please sign in to comment.