diff --git a/aiida/restapi/api.py b/aiida/restapi/api.py index 3f8c40f108..c0c3999135 100644 --- a/aiida/restapi/api.py +++ b/aiida/restapi/api.py @@ -74,7 +74,6 @@ def error_handler(error): else: pass - class AiidaApi(Api): """ AiiDA customized version of the flask_restful Api class @@ -306,7 +305,6 @@ def __init__(self, app=None, **kwargs): strict_slashes=False, resource_class_kwargs=kwargs) - def handle_error(self, e): """ this method handles the 404 "URL not found" exception and return custom message @@ -336,3 +334,4 @@ def handle_error(self, e): else: raise e + diff --git a/aiida/restapi/resources.py b/aiida/restapi/resources.py index d167dbc32d..096d73f33d 100644 --- a/aiida/restapi/resources.py +++ b/aiida/restapi/resources.py @@ -14,7 +14,6 @@ from aiida.restapi.common.utils import Utils - class ServerInfo(Resource): def __init__(self, **kwargs): # Configure utils @@ -88,11 +87,15 @@ def get(self): return self.utils.build_response(status=200, headers=headers, data=data) + ## TODO add the caching support. I cache total count, results, and possibly # set_query class BaseResource(Resource): - ## Each derived class will instantiate a different type of translator. - # This is the only difference in the classes. + """ + Each derived class will instantiate a different type of translator. + This is the only difference in the classes. + """ + def __init__(self, **kwargs): self.trans = None @@ -105,6 +108,7 @@ def __init__(self, **kwargs): self.utils_confs = {k: kwargs[k] for k in utils_conf_keys if k in kwargs} self.utils = Utils(**self.utils_confs) + self.method_decorators = {'get': kwargs.get('get_decorators', [])} def get(self, id=None, page=None): """ @@ -173,8 +177,11 @@ def get(self, id=None, page=None): class Node(Resource): - ##Differs from BaseResource in trans.set_query() mostly because it takes - # query_type as an input and the presence of "tree" result type + """ + Differs from BaseResource in trans.set_query() mostly because it takes + query_type as an input and the presence of additional result types like "tree" + """ + def __init__(self, **kwargs): # Set translator @@ -192,6 +199,7 @@ def __init__(self, **kwargs): self.utils_confs = {k: kwargs[k] for k in utils_conf_keys if k in kwargs} self.utils = Utils(**self.utils_confs) + self.method_decorators = {'get': kwargs.get('get_decorators', [])} def get(self, id=None, page=None): """ diff --git a/setup_requirements.py b/setup_requirements.py index a544a26104..4965521068 100644 --- a/setup_requirements.py +++ b/setup_requirements.py @@ -79,7 +79,7 @@ # Requirements for RESTful API 'REST': [ 'Flask==0.10.1', - 'Flask-RESTful==0.3.5', + 'Flask-RESTful==0.3.6', 'Flask-Cors==3.0.1', 'pyparsing==2.1.10', 'Pattern==2.6',