Skip to content

Commit b0bc673

Browse files
committed
Make evote a module and only worry about wsgi.
I am now handling fcgi-related stuff elsewhere in a dispatcher. This allows us to focus on just the app and not the web integration around it.
1 parent 06894fc commit b0bc673

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

.htaccess

-9
This file was deleted.

index.py __init__.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
#!/users/mtahmed/bin/python
2-
3-
import sys
4-
sys.path.append('/users/mtahmed/.local/lib/python3.3/site-packages')
5-
61
from pyramid.config import Configurator
72
from pyramid.response import Response
83
from pyramid.view import view_config
94

10-
import auth
5+
from . import auth
116

127
@view_config(route_name='main', renderer='templates/base.jinja2')
138
def main(request):
149
'''View for the main landing page.
1510
'''
1611
template_data = dict()
1712

18-
a = auth.Auth()
13+
a = auth.Auth(user_id=request.remote_user)
1914
template_data['user_id'] = a.get_user_id()
2015

2116
return template_data
@@ -24,12 +19,12 @@ def main(request):
2419
def logout(request):
2520
'''View for the logout page. Only redirects to the logout page.
2621
'''
27-
a = auth.Auth()
22+
a = auth.Auth(user_id=request.remote_user)
2823
response = Response()
2924

3025
return a.logout(response)
3126

32-
def make_evote_app():
27+
def make_wsgi_app():
3328
'''This function returns a Pyramid WSGI application.
3429
'''
3530
config = Configurator()
@@ -45,8 +40,3 @@ def make_evote_app():
4540
config.include('pyramid_jinja2')
4641

4742
return config.make_wsgi_app()
48-
49-
if __name__ == '__main__':
50-
import wsgiref.handlers
51-
app = make_evote_app()
52-
wsgiref.handlers.CGIHandler().run(make_evote_app())

auth.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import os
2-
31
class Auth:
42
'''This class will provide the voter authentication.
53
64
Right now it uses the uWaterloo CAS to provide authentication.
75
'''
86
CAS_LOGOUT_URL='https://cas.uwaterloo.ca/cas/logout'
97

10-
def __init__(self):
11-
self.user_id = os.environ['REMOTE_USER']
8+
def __init__(self, user_id, is_authed=True):
9+
self.user_id = user_id
1210
# The user is denied if auth fails before they get here so the user must
1311
# already be authenticated.
14-
self.is_authed = True
12+
self.is_authed = is_authed
1513

1614
def get_user_id(self):
1715
return self.user_id

0 commit comments

Comments
 (0)