From 0088ab0904a30fda8083e742abc4d7fa5dc66d9f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 8 Sep 2011 01:49:33 -0400 Subject: [PATCH] further hurm --- toy.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/toy.py b/toy.py index 52c632d..647331f 100644 --- a/toy.py +++ b/toy.py @@ -10,13 +10,88 @@ from resources import Interface, Resource api = Interface() +@api.map('bookmarks') class Bookmarks(Resource): - """docstring for Bookmarks""" - pass + """Haystack's Bookmarks Resource.""" + + __bookmarks = {} + + # get(*args, **kwargs) <-- automatic + + def element_get(self, ri): + return self.__bookmarks.get(ri) + + def element_put(self, ri, data): + pass + + def element_patch(self, ri, data): + pass + + def element_post(self, ri, data): + pass + + def element_delete(self, ri): + pass + + def collection_get(self, **options): + return self.__bookmarks.values() + + def collection_put(self, ri, data): + pass + + def collection_patch(self, ri, data): + pass + + def collection_post(self, ri, data): + pass + + def collection_delete(self, ri): + pass -api.map(Bookmarks, 'bookmarks') + def __from_json(ri): + pass + + + +# api.map('bookmarks', Bookmarks) + + +# @api.when.bookmarks.post +def test(x): + print 'hi' + + +#api.before_get +#api.before_put +#api.before_post +#api.before_delete +#api.before_patch + +#api.after_get +#api.after_put +#api.after_post +#api.after_delete +#api.after_patch + # print api -print api.bookmarks +print api.bookmarks.uuid +print api.bookmarks.get() + +# print api.bookmarks.get(id='0') + +# >>> print api.bookmarks[00001] +# +# You'll be able to use this as a reference in other objects + +# >>> print api.bookmarks[00001].get() +# + + +# >>> api.bookmarks[00001].content('json').get() +# + + +# print test('x') # print api.resources \ No newline at end of file