Piston debugging + further handler development
This commit is contained in:
parent
c7ad4be6e4
commit
f7980de01f
|
@ -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
|
||||
|
|
|
@ -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<itemId>\d+)/$', buyableItemRes),
|
||||
url(r'buyable/types/$', buyableTypeRes),
|
||||
|
||||
url(r'transaction/transact/', transactionTransactRes),
|
||||
url(r'transaction/types/', transactionTypeRes),
|
||||
|
|
|
@ -4,6 +4,7 @@ import ldap
|
|||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
PISTON_DISPLAY_ERRORS = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@domain.com'),
|
||||
|
|
Loading…
Reference in New Issue