def getMimeType(self, contenttype, format_types, result=None):
supported_types = ["text/plain", "text/html", "application/yaml", "application/json"]
CONTENT_TYPES = {
"text/plain": str,
"text/html": self._text2htmlSerializer,
"application/yaml": self._resultyamlSerializer,
"application/json": j.db.serializers.getSerializerType('j').dumps
}
if not contenttype:
serializer = format_types["text"]["serializer"]
return CONTENT_TYPE_HTML, serializer
elif isinstance(result, types.GeneratorType):
return 'application/octet-stream', lambda x: x
else:
mimeType = mimeparse.best_match(supported_types, contenttype)
serializer = CONTENT_TYPES[mimeType]
return mimeType, serializer
评论列表
文章目录