示例#1
0
def catalogs_json():
	'''
		Since the object is not JSON serializable.
		We could firstly convert it to a dict.
		Then a list of dict which is JSON serializable.
	'''
	return utils.json_response([ x.serialize for x in models.select_catalogs_all() ], 200)
示例#2
0
def catalogs_json():
    '''
        Since the object is not JSON serializable.
        We could firstly convert it to a dict.
        Then a list of dict which is JSON serializable.
    '''
    return utils.json_response(
        [x.serialize for x in models.select_catalogs_all()], 200)
示例#3
0
def catalogs_xml():
	'''
		Convert list of unserializable object to xml:
		1. Retrive data
		2. Turn each object to xml
		3. Wrap them with a xml tag
	'''
	return utils.xml_response(utils.list_to_xml('catalogs',
		[ utils.dict_to_xml('catalog', x.serialize) for x in models.select_catalogs_all() ]), 200)
示例#4
0
def catalogs_xml():
    '''
        Convert list of unserializable object to xml:
        1. Retrive data
        2. Turn each object to xml
        3. Wrap them with a xml tag
    '''
    return utils.xml_response(
        utils.list_to_xml('catalogs', [
            utils.dict_to_xml('catalog', x.serialize)
            for x in models.select_catalogs_all()
        ]), 200)