def handle(self): response = asdict( self.server.odb.get_cache_builtin(self.server.cluster_id, self.request.input.cache_id)) response['current_size'] = self.cache.get_size( _COMMON_CACHE.TYPE.BUILTIN, response['name']) self.response.payload = response
def field_getter(subject: object, field_name: str, default: any = None): """ Gets a field value from a dict or object """ value = None if type(subject) is dict and field_name in subject: value = subject.get(field_name, default) if hasattr(subject, field_name): value = getattr(subject, field_name, default) if isinstance(value, BaseModel): value: dict = value.dict() if isinstance(value, BaseDbModel): value: dict = asdict( value, exclude=["created_by", "created_at", "updated_at"]) if value: return value return default
def as_dict(self): return asdict(self, **self.__dictfields__)