diff --git a/resources/core.py b/resources/core.py index 555ba54..2edb809 100644 --- a/resources/core.py +++ b/resources/core.py @@ -13,6 +13,19 @@ from uuid import uuid4 __all__ = ('Resource', 'Interface', 'Element') + +def method_not_allowed(f): + def decorator(*args, **kwargs): + try: + return f(*args, **kwargs) + except Exception: + # print why + return None + + return decorator + + + class Resource(object): """A RESTful Resource.""" @@ -24,11 +37,27 @@ class Resource(object): super(Resource, self).__init__() + @method_not_allowed + def get(self, **options): + + + r = self.collection_get() + + return r + # try: + # self.get = self.element_get + + # except AttributeError: + # pass + + def __repr__(self): return ''.format(self.name) + + class Interface(object): """The RESTful API Interface.""" @@ -78,12 +107,12 @@ class Interface(object): class Element(object): """A RESTful Element.""" - def __init__(self): + def __init__(self, resource=None): + self.resource = resource self.uuid = uuid4().hex self.id = None - super(Element, self).__init__()