[Python-es] Duda sobre bottle

Juan BC jbc.develop en gmail.com
Jue Mar 21 21:13:46 CET 2013


algo asi

@get('/topology') # or @route('/login')
def topology_form():
        info_links =get_links() # Devuelve un fichero json
        info_interfaces=get_
interfaces() # devuelve un fichero json
        info,links=matriz_links(info_links) # Devuelve dos listas con
la informacion que me interesa del json que me dice cuantos puertos
tengo por switch
        switc= get_ovs(info_interfaces)    #Devuelve la lista de
switchs en mi red
        ma = matriz_adjacencia(links,switch) # Devuelve una lista a
indicar como los switchs anteriores se conectan.
        return {"matrix": ma}

run(host='193.136.93.140', port=8081)

El día 21 de marzo de 2013 17:12, Juan BC <jbc.develop en gmail.com> escribió:
> en bottle si retornar un objeto dict automaticamente se serializa a json
>
> El día 21 de marzo de 2013 17:07, Rafael Gomes <rggg88 en hotmail.com> escribió:
>> Ok y para serializarlo utilizo o dump de la biblioteca json o uso el pickle
>> y parecidos?
>> Gracias por tu ayuda :).
>>
>> ________________________________
>> Date: Thu, 21 Mar 2013 21:04:20 +0100
>> From: niwi en niwi.be
>> To: python-es en python.org
>> Subject: Re: [Python-es] Duda sobre bottle
>>
>>
>> Si es un objecto dict o list deberías serializarlo con json. En mi opinión.
>>
>> Andrey
>>
>>
>> El 21 de marzo de 2013 19:13, Rafael Gomes <rggg88 en hotmail.com> escribió:
>>
>> Hola amigos como estan?
>> Disculpen molestar pero estaba a seguir un tutorial sobre el bottle para
>> hacer los pedidos http como get, put a partir de esta pagina de la bottle
>> http://bottlepy.org/docs/dev/tutorial.html
>> Todavia hice este:
>> http://www.clubdelphi.com/foros/showthread.php?t=79318
>>
>> Y entonces luego solo para ver como esto realmente funcionaba hice el
>> siguiente programa:
>>
>> from bottle import run, get, post, request
>> from json import loads
>> from funcoes_links import get_links, matriz_links, record_links,
>> list_port_links, matriz_adjacencia, matriz_adjacencia_bw
>> from funcoes_interfaces import get_interfaces,get_ovs,
>> get_port,get_interface_list, get_list_port_host, get_list_lb
>> from funcoes_estatisticas import get_statistics, matriz_statistics,
>> filter_statistics
>>
>>
>> @get('/topology') # or @route('/login')
>> def topology_form():
>>         info_links =get_links() # Devuelve un fichero json
>>         info_interfaces=get_interfaces() # devuelve un fichero json
>>         info,links=matriz_links(info_links) # Devuelve dos listas con la
>> informacion que me interesa del json que me dice cuantos puertos tengo por
>> switch
>>         switc= get_ovs(info_interfaces)    #Devuelve la lista de switchs en
>> mi red
>>         return matriz_adjacencia(links,switch) # Devuelve una lista a
>> indicar como los switchs anteriores se conectan.
>>
>> run(host='193.136.93.140', port=8081)
>>
>>
>> Al executr recibo el siguiente mensaje: Unsupported response type: <type
>> 'list'>
>>
>> Se que el problema es la informacion venir, en list pues si la pongo en
>> string el le bien, mi duda es si hay alguna forma de contornar este
>> problema? es que normalmente he guardado la informacion en listas y
>> dicionarios, y tambien con dicionarios da error.
>>
>> Muchas gracias por vuestra ayuda e disculpen :)
>>
>> Que tengan un buen resto de dia.
>>
>> Saludos cordiales Rafael.
>>
>>
>> _______________________________________________
>> Python-es mailing list
>> Python-es en python.org
>> http://mail.python.org/mailman/listinfo/python-es
>> FAQ: http://python-es-faq.wikidot.com/
>>
>>
>>
>>
>> --
>> Andrey Antukh - Андрей Антух - <niwi en niwi.be>
>> http://www.niwi.be/about.html
>> http://www.kaleidos.net/A5694F/
>>
>> "Linux is for people who hate Windows, BSD is for people who love UNIX"
>> "Social Engineer -> Because there is no patch for human stupidity"
>>
>> _______________________________________________ Python-es mailing list
>> Python-es en python.org http://mail.python.org/mailman/listinfo/python-es FAQ:
>> http://python-es-faq.wikidot.com/
>>
>> _______________________________________________
>> Python-es mailing list
>> Python-es en python.org
>> http://mail.python.org/mailman/listinfo/python-es
>> FAQ: http://python-es-faq.wikidot.com/
>>
>
>
>
> --
> Juan B Cabral



-- 
Juan B Cabral


Más información sobre la lista de distribución Python-es