from django.conf.urls.defaults import * from piston.resource import Resource from piston.authentication import HttpBasicAuthentication from api2.handlers import * # taken from # http://www.robertshady.com/content/creating-very-basic-api-using-python-django-and-piston class CsrfExemptResource( Resource ): def __init__( self, handler, authentication = None ): super( CsrfExemptResource, self ).__init__( handler, authentication ) self.csrf_exempt = getattr( self.handler, 'csrf_exempt', True ) auth = HttpBasicAuthentication(realm="Freitagsrundenkassensystemapi") ad = {'authentication': auth} buyableItemRes = CsrfExemptResource(handler=BuyableItemHandler, **ad) buyableTypeRes = CsrfExemptResource(handler=BuyableTypeHandler, **ad) transactionTransactRes = CsrfExemptResource(handler=TransactionTransactHandler, **ad) transactionTypeRes = CsrfExemptResource(handler=TransactionTypeHandler, **ad) authBlobRes = Resource(handler=AuthBlobHandler, **ad) configRes = Resource(handler=ConfigHandler, **ad) urlpatterns = patterns('', url(r'buyable/item/$', buyableItemRes), url(r'buyable/item/(?P\d+)/$', buyableItemRes), url(r'buyable/types/$', buyableTypeRes), url(r'transaction/transact/$', transactionTransactRes), url(r'transaction/types/$', transactionTypeRes), url(r'auth/blob/$', authBlobRes), url(r'config/$', configRes), )