Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove legacy WSGI handlers.

PYTHONPATH will be set in mod_wsgi's conf.
  • Loading branch information...
commit f7fbe4e50c21896ab75615c0ab52570c1dd79b10 1 parent 43d6512
Aymeric Augustin aaugustin authored
1  TODO
View
@@ -1,2 +1 @@
* allow users to "claim" legacy feeds (might do this by hand.)
-* get rid of wsgi-scripts, move useful functions to django_*.wsgi
22 tracdb/wsgiauth.py
View
@@ -0,0 +1,22 @@
+# WSGI auth handlers for Trac
+
+from django import db
+from django.contrib.auth.models import User
+
+def check_password(environ, user, password):
+ try:
+ user = User.objects.get(username=user, is_active=True)
+ if user.check_password(password):
+ return True
+ return False
+ except User.DoesNotExist:
+ return None
+ finally:
+ db.connection.close()
+
+def groups_for_user(environ, user):
+ try:
+ u = User.objects.get(username=user)
+ except User.DoesNotExist:
+ return []
+ return [g.name.lower() for g in u.groups.all()]
28 wsgi-scripts/docs.wsgi
View
@@ -1,28 +0,0 @@
-import os
-import sys
-import site
-
-SITE_PACKAGES = '/home/www/djangoproject.com/lib/python2.6/site-packages'
-
-# Remember original sys.path.
-prev_sys_path = list(sys.path)
-
-# Add each new site-packages directory.
-site.addsitedir(SITE_PACKAGES)
-
-# Reorder sys.path so new directories at the front.
-new_sys_path = []
-for item in list(sys.path):
- if item not in prev_sys_path:
- new_sys_path.append(item)
- sys.path.remove(item)
-sys.path[:0] = new_sys_path
-
-# Bootstrap Django
-here = os.path.dirname(__file__)
-parent = os.path.dirname(here)
-sys.path.append(parent)
-os.environ['DJANGO_SETTINGS_MODULE'] = 'django_docs.settings'
-
-import django.core.handlers.wsgi
-application = django.core.handlers.wsgi.WSGIHandler()
51 wsgi-scripts/svnauth.wsgi
View
@@ -1,51 +0,0 @@
-"""
-This file's a hack working around WSGIAuthGroupScript not working.
-"""
-
-import os
-import sys
-import site
-
-#
-# Bootstrap
-#
-
-SITE_PACKAGES = '/home/www/djangoproject.com/lib/python2.6/site-packages'
-
-# Remember original sys.path.
-prev_sys_path = list(sys.path)
-
-# Add each new site-packages directory.
-site.addsitedir(SITE_PACKAGES)
-
-# Reorder sys.path so new directories at the front.
-new_sys_path = []
-for item in list(sys.path):
- if item not in prev_sys_path:
- new_sys_path.append(item)
- sys.path.remove(item)
-sys.path[:0] = new_sys_path
-
-# Bootstrap Django
-here = os.path.dirname(__file__)
-parent = os.path.dirname(here)
-sys.path.append(parent)
-os.environ['DJANGO_SETTINGS_MODULE'] = 'django_www.settings'
-
-#
-# WSGI auth handler
-#
-from django import db
-from django.contrib.auth.models import User
-
-def check_password(environ, user, password):
- try:
- user = User.objects.get(username=user, is_active=True)
- if user.check_password(password):
- # HACK ALERT!
- return 'committers' in [g.name.lower() for g in user.groups.all()]
- return False
- except User.DoesNotExist:
- return None
- finally:
- db.connection.close()
59 wsgi-scripts/www.wsgi
View
@@ -1,59 +0,0 @@
-import os
-import sys
-import site
-
-#
-# Bootstrap
-#
-
-SITE_PACKAGES = '/home/www/djangoproject.com/lib/python2.6/site-packages'
-
-# Remember original sys.path.
-prev_sys_path = list(sys.path)
-
-# Add each new site-packages directory.
-site.addsitedir(SITE_PACKAGES)
-
-# Reorder sys.path so new directories at the front.
-new_sys_path = []
-for item in list(sys.path):
- if item not in prev_sys_path:
- new_sys_path.append(item)
- sys.path.remove(item)
-sys.path[:0] = new_sys_path
-
-# Bootstrap Django
-here = os.path.dirname(__file__)
-parent = os.path.dirname(here)
-sys.path.append(parent)
-os.environ['DJANGO_SETTINGS_MODULE'] = 'django_www.settings'
-
-#
-# WSGI application
-#
-import django.core.handlers.wsgi
-application = django.core.handlers.wsgi.WSGIHandler()
-
-#
-# WSGI auth handlers
-#
-from django import db
-from django.contrib.auth.models import User
-
-def check_password(environ, user, password):
- try:
- user = User.objects.get(username=user, is_active=True)
- if user.check_password(password):
- return True
- return False
- except User.DoesNotExist:
- return None
- finally:
- db.connection.close()
-
-def groups_for_user(environ, user):
- try:
- u = User.objects.get(username=user)
- except User.DoesNotExist:
- return []
- return [g.name.lower() for g in u.groups.all()]
Please sign in to comment.
Something went wrong with that request. Please try again.