Source

propaneweb / propaneweb / views.py

import propaneweb.shortcuts as ps

def index(request):
    return ps.render(request, "index.html")

def login(request):
    "Handle login form & POST"
    from django.contrib.auth import authenticate, login as auth_login
    if request.user.is_authenticated():
        return ps.HttpResponseRedirect(request.GET.get("next", "/"))
    if request.method == "POST":
        user = authenticate(
            username=request.POST["username"],
            password=request.POST["password"])
        if user is not None:
            auth_login(request, user)
            return ps.HttpResponseRedirect(request.GET.get("next", "/"))
        else:
            return ps.render(request, "login.html", {"badlogin": True, 'pw': repr(request.POST["password"])})

    return ps.render(request, "login.html")

def meta(request):
    "Show some meta info for debugging"
    rows = []
    rows.append(("path", request.get_full_path()))
    rows.append(("path_info", request.path_info))
    rows.append(("method", request.method))
    rows.append(("GET", request.GET))
    rows.append(("POST", request.POST))
    rows.append(("dir", dir(request)))
    rows.append(("secure", request.is_secure()))
    return ps.render(request, "meta.html", {"rows": rows})