exempt publishing api from csrf
[wolnelektury.git] / apps / api / helpers.py
1 # -*- coding: utf-8 -*-
2
3 from time import mktime
4 from piston.resource import Resource
5
6 def timestamp(dtime):
7     "converts a datetime.datetime object to a timestamp int"
8     return int(mktime(dtime.timetuple()))
9
10 class CsrfExemptResource(Resource):
11     """A Custom Resource that is csrf exempt"""
12     def __init__(self, handler, authentication=None):
13         super(CsrfExemptResource, self).__init__(handler, authentication)
14         self.csrf_exempt = getattr(self.handler, 'csrf_exempt', True)