Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 454daaeb19
Fetching contributors…

Cannot retrieve contributors at this time

file 14 lines (10 sloc) 0.481 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14
from pyramid.httpexceptions import HTTPForbidden
from pyramid.renderers import get_renderer


def add_base_template(event):
    base = get_renderer('templates/base.pt').implementation()
    event.update({'base': base})


def csrf_validation(event):
    if event.request.method == "POST":
        token = event.request.POST.get("_csrf")
        if token is None or token != event.request.session.get_csrf_token():
            raise HTTPForbidden('CSRF token is missing or invalid')
Something went wrong with that request. Please try again.