from piston.handler import BaseHandler from piston.utils import rc from k4ever.buyable.models import * from k4ever.transaction.models import * class BuyableItemHandler(BaseHandler): allowed_methods = ('GET', 'POST') #fields = ('id', 'description') model = Buyable exclude = ('_state',) def read(self, request, itemId=None): if itemId == None: return Buyable.objects.all() try: return Buyable.objects.get(id=itemId) except Buyable.DoesNotExist: error = rc.NOT_FOUND error.write("This buyable does not exist in our database") return error class BuyableTypeHandler(BaseHandler): allowed_methods = ('GET',) model = BuyableType class TransactionTransactHandler(BaseHandler): allowed_methods = ('GET', 'POST') model = Transaction class TransactionTypeHandler(BaseHandler): allowed_methods = ('GET',) model = TransactionType class AuthBlobHandler(BaseHandler): # allowed_methods = ('GET', 'POST') # model = pass