X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2common%2Fviews%2Froute.py;h=9366a3218e182af424684796893ef4aff4bd0586;hb=586f039c73d102429517cb6068de4342976e4e3f;hp=0941f5814c1e5755e1120d5927044a83745952dc;hpb=8a84a2ef10be51faf50b2880a3a94194d64459ba;p=pti%2Fo2.git diff --git a/o2common/views/route.py b/o2common/views/route.py index 0941f58..9366a32 100644 --- a/o2common/views/route.py +++ b/o2common/views/route.py @@ -30,6 +30,8 @@ from flask_restx.model import Model from flask_restx.fields import List, Nested, String from flask_restx.utils import unpack +from o2common.views.route_exception import BadRequestException + from o2common.helper import o2logging logger = o2logging.get_logger(__name__) @@ -96,8 +98,8 @@ class o2_marshal_with(marshal_with): req_args = request.args mask = self._gen_mask_from_selector(**req_args) - - # mask = self.mask + if mask == '': + mask = self.mask # if has_request_context(): # mask_header = current_app.config["RESTX_MASK_HEADER"] @@ -128,11 +130,13 @@ class o2_marshal_with(marshal_with): mask_val = '' if 'all_fields' in kwargs: all_fields_without_space = kwargs['all_fields'].replace(" ", "") - all_fields = all_fields_without_space.lower() - if 'true' == all_fields: - selector = self.__gen_selector_from_model_with_value( - self.fields) - mask_val = self.__gen_mask_from_selector(selector) + logger.info('all_fields selector value is {}'.format( + all_fields_without_space)) + # all_fields = all_fields_without_space.lower() + # if 'true' == all_fields: + selector = self.__gen_selector_from_model_with_value( + self.fields) + mask_val = self.__gen_mask_from_selector(selector) elif 'fields' in kwargs and kwargs['fields'] != '': fields_without_space = kwargs['fields'].replace(" ", "") @@ -211,6 +215,9 @@ class o2_marshal_with(marshal_with): if '/' in f: self.__update_selector_tree_value(selector, f, val) continue + if f not in self.fields: + raise BadRequestException( + 'Selector attribute {} not found'.format(f)) selector[f] = val def __update_selector_tree_value(self, m: dict, filter: str, val: bool):