Piston debugging + further handler development

This commit is contained in:
seba 2011-09-28 14:31:21 +02:00
parent c7ad4be6e4
commit f7980de01f
3 changed files with 16 additions and 4 deletions

View File

@ -1,4 +1,5 @@
from piston.handler import BaseHandler from piston.handler import BaseHandler
from piston.utils import rc
from k4ever.buyable.models import * from k4ever.buyable.models import *
from k4ever.transaction.models import * from k4ever.transaction.models import *
@ -8,8 +9,15 @@ class BuyableItemHandler(BaseHandler):
model = Buyable model = Buyable
exclude = ('_state',) exclude = ('_state',)
#def read(self, request): def read(self, request, itemId=None):
# return Buyable.objects.get(id=1) 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): class BuyableTypeHandler(BaseHandler):
allowed_methods = ('GET',) allowed_methods = ('GET',)
@ -24,4 +32,6 @@ class TransactionTypeHandler(BaseHandler):
model = TransactionType model = TransactionType
class AuthBlobHandler(BaseHandler): class AuthBlobHandler(BaseHandler):
# allowed_methods = ('GET', 'POST')
# model =
pass pass

View File

@ -15,8 +15,9 @@ transactionTypeRes = Resource(handler=TransactionTypeHandler, **ad)
authBlobRes = Resource(handler=AuthBlobHandler, **ad) authBlobRes = Resource(handler=AuthBlobHandler, **ad)
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'buyable/item/', buyableItemRes), url(r'buyable/item/$', buyableItemRes),
url(r'buyable/types/', buyableTypeRes), url(r'buyable/item/(?P<itemId>\d+)/$', buyableItemRes),
url(r'buyable/types/$', buyableTypeRes),
url(r'transaction/transact/', transactionTransactRes), url(r'transaction/transact/', transactionTransactRes),
url(r'transaction/types/', transactionTypeRes), url(r'transaction/types/', transactionTypeRes),

View File

@ -4,6 +4,7 @@ import ldap
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
PISTON_DISPLAY_ERRORS = DEBUG
ADMINS = ( ADMINS = (
# ('Your Name', 'your_email@domain.com'), # ('Your Name', 'your_email@domain.com'),