From f7980de01f518e3a831480d9456e4026403424b2 Mon Sep 17 00:00:00 2001 From: seba Date: Wed, 28 Sep 2011 14:31:21 +0200 Subject: [PATCH] Piston debugging + further handler development --- k4ever/api2/handlers.py | 14 ++++++++++++-- k4ever/api2/urls.py | 5 +++-- k4ever/settings.py | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/k4ever/api2/handlers.py b/k4ever/api2/handlers.py index e0e426b..543151f 100644 --- a/k4ever/api2/handlers.py +++ b/k4ever/api2/handlers.py @@ -1,4 +1,5 @@ from piston.handler import BaseHandler +from piston.utils import rc from k4ever.buyable.models import * from k4ever.transaction.models import * @@ -8,8 +9,15 @@ class BuyableItemHandler(BaseHandler): model = Buyable exclude = ('_state',) - #def read(self, request): - # return Buyable.objects.get(id=1) + 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',) @@ -24,4 +32,6 @@ class TransactionTypeHandler(BaseHandler): model = TransactionType class AuthBlobHandler(BaseHandler): + # allowed_methods = ('GET', 'POST') + # model = pass diff --git a/k4ever/api2/urls.py b/k4ever/api2/urls.py index 4fed12a..2f102be 100644 --- a/k4ever/api2/urls.py +++ b/k4ever/api2/urls.py @@ -15,8 +15,9 @@ transactionTypeRes = Resource(handler=TransactionTypeHandler, **ad) authBlobRes = Resource(handler=AuthBlobHandler, **ad) urlpatterns = patterns('', - url(r'buyable/item/', buyableItemRes), - url(r'buyable/types/', buyableTypeRes), + 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), diff --git a/k4ever/settings.py b/k4ever/settings.py index b77abd7..a814103 100644 --- a/k4ever/settings.py +++ b/k4ever/settings.py @@ -4,6 +4,7 @@ import ldap DEBUG = True TEMPLATE_DEBUG = DEBUG +PISTON_DISPLAY_ERRORS = DEBUG ADMINS = ( # ('Your Name', 'your_email@domain.com'),