(self,
                model,
                model_fields=None,
                meta=None,
                status_code=HTTP_STATUS_CODE_OK)
return response
Create json response from a database models.

        Args:
            model: Instance of a timesketch database model
            model_fields: Dictionary describing the resulting schema
            meta: Dictionary holding any metadata for the result
            status_code: Integer used as status_code in the response

        Returns:
            Response in json format (instance of flask.wrappers.Response)
Create json response from a database models.
Create json response from a database models .
def to_json(self,
                model,
                model_fields=None,
                meta=None,
                status_code=HTTP_STATUS_CODE_OK):
        """Create json response from a database models.

        Args:
            model: Instance of a timesketch database model
            model_fields: Dictionary describing the resulting schema
            meta: Dictionary holding any metadata for the result
            status_code: Integer used as status_code in the response

        Returns:
            Response in json format (instance of flask.wrappers.Response)
        """
        if not meta:
            meta = dict()

        schema = {'meta': meta, 'objects': []}

        if model:
            if not model_fields:
                try:
                    model_fields = self.fields_registry[model.__tablename__]
                except AttributeError:
                    model_fields = self.fields_registry[model[0].__tablename__]
            schema['objects'] = [marshal(model, model_fields)]

        response = jsonify(schema)
        response.status_code = status_code
        return response
def to_json ( self , model , model_fields = None , meta = None , status_code = HTTP_STATUS_CODE_OK ) : if not meta : meta = dict ( ) schema = { 'meta' : meta , 'objects' : [ ] } if model : if not model_fields : try : model_fields = self . fields_registry [ model . __tablename__ ] except AttributeError : model_fields = self . fields_registry [ model [ 0 ] . __tablename__ ] schema [ 'objects' ] = [ marshal ( model , model_fields ) ] response = jsonify ( schema ) response . status_code = status_code return response