from pyramid.events import  subscriber, NewRequest

@subscriber(NewRequest)
def csrf_validation(event):
    pass
#    print(event.request.method, event.request.url, event.request.query_string)
#    if event.request.method == "POST" and not event.request.is_xhr:
#        token = event.request.POST.get("_csrf")
#        print('CSRF POST token is ' + token + ' vs Server ' + event.request.session.get_csrf_token())

#        if token is None or token != event.request.session.get_csrf_token():
#            raise HTTPForbidden('CSRF token is missing or invalid ' + token + ' Original ' + event.request.session.get_csrf_token())