#!/usr/bin/python
import cgi
from albatross import SimpleContext

form = cgi.FieldStorage()
ctx = SimpleContext('.')
ctx.locals.form = form
for name in form.keys():
    if type(form[name]) is type([]):
        value = []
        for elem in form[name]:
            value.append(elem.value)
    else:
        value = form[name].value
    setattr(ctx.locals, name, value)
templ = ctx.load_template('form.html')
templ.to_html(ctx)

print 'Content-Type: text/html'
print
ctx.flush_content()
