-
-class ProblemDetails(Serializer):
- def __init__(self, namespace: O2Namespace, code: int, detail: str,
- title=None, instance=None
- ) -> None:
- self.ns = namespace
- self.status = code
- self.detail = detail
- self.type = request.path
- self.title = title if title is not None else self.getTitle(code)
- self.instance = instance if instance is not None else []
-
- def getTitle(self, code):
- return HTTPStatus(code).phrase
-
- def abort(self):
- self.ns.abort(self.status, self.detail, **self.serialize())
-
- def serialize(self):
- details = {}
- for key in dir(self):
- if key == 'ns' or key.startswith('__') or\
- callable(getattr(self, key)):
- continue
- else:
- details[key] = getattr(self, key)
- return details
+ def __set_default_mask(self, selector: dict, val: bool = True):
+ mask = getattr(self.fields, "__mask__")
+ if not mask:
+ selector_all = self.__gen_selector_from_model_with_value(
+ self.fields)
+ for s in selector_all:
+ selector[s] = val
+ return
+ default_selector = str(mask).strip(' {}')
+ self.__update_selector_value(selector, default_selector, val)