Пример #1
0
def format_json(obj):
    # FIXME: Should turn the key names into camel case, since that's more JSONy
    dict = obj.as_dictionary()
    response = Response()
    response.content = json.dumps(dict)
    response.content_type = "application/json"
    return response
Пример #2
0
def format_kml(obj):
    etree = ElementTree.ElementTree(ElementTree.fromstring("<kml><Document /></kml>"))
    add_kml_elem(obj, etree)
    output = StringIO.StringIO()
    etree.write(output)
    response = Response()
    response.content = output.getvalue()
    response.content_type = "application/vnd.google-earth.kml+xml"
    return response