Code Review
/
pti
/
o2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Update error handling; update selector; change delete response code to 200
[pti/o2.git]
/
o2common
/
views
/
route.py
diff --git
a/o2common/views/route.py
b/o2common/views/route.py
index
2c93d77
..
0941f58
100644
(file)
--- a/
o2common/views/route.py
+++ b/
o2common/views/route.py
@@
-130,7
+130,9
@@
class o2_marshal_with(marshal_with):
all_fields_without_space = kwargs['all_fields'].replace(" ", "")
all_fields = all_fields_without_space.lower()
if 'true' == all_fields:
all_fields_without_space = kwargs['all_fields'].replace(" ", "")
all_fields = all_fields_without_space.lower()
if 'true' == all_fields:
- mask_val = ''
+ 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(" ", "")
elif 'fields' in kwargs and kwargs['fields'] != '':
fields_without_space = kwargs['fields'].replace(" ", "")
@@
-148,6
+150,7
@@
class o2_marshal_with(marshal_with):
selector = {}
self.__update_selector_value(selector, fields_without_space, True)
selector = {}
self.__update_selector_value(selector, fields_without_space, True)
+ self.__set_default_mask(selector)
mask_val = self.__gen_mask_from_selector(selector)
mask_val = self.__gen_mask_from_selector(selector)
@@
-160,6
+163,7
@@
class o2_marshal_with(marshal_with):
self.__update_selector_value(
selector, exclude_fields_without_space, False)
self.__update_selector_value(
selector, exclude_fields_without_space, False)
+ self.__set_default_mask(selector)
mask_val = self.__gen_mask_from_selector(selector)
elif 'exclude_default' in kwargs and kwargs['exclude_default'] != '':
mask_val = self.__gen_mask_from_selector(selector)
elif 'exclude_default' in kwargs and kwargs['exclude_default'] != '':
@@
-200,14
+204,14
@@
class o2_marshal_with(marshal_with):
selector[i] = default_val
return selector
selector[i] = default_val
return selector
- def __update_selector_value(self,
default_
selector: dict, filter: str,
+ def __update_selector_value(self, selector: dict, filter: str,
val: bool):
fields = filter.split(',')
for f in fields:
if '/' in f:
val: bool):
fields = filter.split(',')
for f in fields:
if '/' in f:
- self.__update_selector_tree_value(
default_
selector, f, val)
+ self.__update_selector_tree_value(selector, f, val)
continue
continue
-
default_
selector[f] = val
+ selector[f] = val
def __update_selector_tree_value(self, m: dict, filter: str, val: bool):
filter_list = filter.split('/', 1)
def __update_selector_tree_value(self, m: dict, filter: str, val: bool):
filter_list = filter.split('/', 1)
@@
-230,3
+234,7
@@
class o2_marshal_with(marshal_with):
mask_li.append(k)
return '{%s}' % ','.join(mask_li)
mask_li.append(k)
return '{%s}' % ','.join(mask_li)
+
+ def __set_default_mask(self, selector: dict, val: bool = True):
+ default_selector = str(getattr(self.fields, "__mask__"))[1:-1]
+ self.__update_selector_value(selector, default_selector, val)