|
|
@ -30,8 +30,13 @@ class BaseResource(object): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __getitem__(self, key): |
|
|
|
def __getitem__(self, key): |
|
|
|
klass = self.nodes[key] |
|
|
|
klass = self.nodes.get(key, None) |
|
|
|
return klass(key, self) |
|
|
|
if klass: |
|
|
|
|
|
|
|
return klass(key, self) |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
return super().__getitem__(key) |
|
|
|
|
|
|
|
except AttributeError: |
|
|
|
|
|
|
|
raise KeyError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
@ -210,3 +215,10 @@ class PaginationResourceMixin(object): |
|
|
|
params = self.query_params(*args, **kwargs) |
|
|
|
params = self.query_params(*args, **kwargs) |
|
|
|
return self.request.resource_url(self, query=params) |
|
|
|
return self.request.resource_url(self, query=params) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __getitem__(self, key): |
|
|
|
|
|
|
|
model = self.request.dbsession.query(self.sql_model_class).get(key) |
|
|
|
|
|
|
|
if not model: |
|
|
|
|
|
|
|
raise KeyError() |
|
|
|
|
|
|
|
return self.child_resource_class.from_sqla(model, self) |
|
|
|
|
|
|
|
|
|
|
|