apply.py 1.64 KB
Newer Older
Jean Michel Rouly's avatar
Jean Michel Rouly committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import ldap
import site

site.addsitedir('/srv/http/go/wsgi')
import library
import goconfig

def application(environ, start_response):

  # Construct the default body, along with its header/footer wrapper.
  body = []
  f = open(goconfig.doc_root + "/site_data/top.part", "r")
  top_part = f.read()
  f.close()
  f = open(goconfig.doc_root + "/site_data/bottom.part", "r")
  bottom_part = f.read()
  f.close()

19
20
21
22
23
24
25
26
27
28
29
  if environ["REQUEST_METHOD"] == "POST":
    
    # Grab user data, cut off non-relevant fields.
    data = environ['wsgi.input']
    data = library.parse_post_data( data )
    
    user = data['user']
    name = data['name']
    desc = data['desc']


Jean Michel Rouly's avatar
Jean Michel Rouly committed
30
31
32
  apply_form = """
    <form action="" method="post">
      <br />
33
34
35
      <label for="user">username (NetID)</label>
      <br /><br />
      <input type="text" id="user" name="user" value="" />
Jean Michel Rouly's avatar
Jean Michel Rouly committed
36
      <br /><br />
37
      <label for="name">full name</label>
Jean Michel Rouly's avatar
Jean Michel Rouly committed
38
      <br /><br />
39
      <input type="text" id="name" name="name" value="" />
Jean Michel Rouly's avatar
Jean Michel Rouly committed
40
      <br /><br />
41
      <label for="desc">user description</label>
Jean Michel Rouly's avatar
Jean Michel Rouly committed
42
      <br /><br />
43
44
45
46
      <textarea id="desc" name="desc"></textarea>
      <p>Submitting an application indicates implicit acceptance of the
      <a href="http://srct.gmu.edu/usage-policy">SRCT Usage Policy</a>.</p>
      <input type="submit" name="submit" value="APPLY" />
Jean Michel Rouly's avatar
Jean Michel Rouly committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
      <br /><br />
    </form>
  """
  body.append( apply_form )

  body = ''.join( body )
  response = top_part + body + bottom_part

  status = '200 OK'
  response_headers = [('Content-type', 'text/html'),
                      ('Content-Length', str(len(response)))]
  start_response(status, response_headers)

  return [response]