Ciao, 2017-02-23 22:20 GMT+01:00 Carlos Catucci <carlos.catu...@gmail.com>:
> @is_session_alive > def test(request): > > return HttpResponse('OK') > > il deco e' il seguente > > def is_session_alive(function): > > def wrap(request, *args, **kwargs): > > retvals = {'test': ''OK'} > return retvals > > return HttpResponse( wrap ) > probabilmente l'errore sta nel wrapper; prima cosiderazione, il decoratore dovrebbe restituire solo wrap e non HttpResponse(wrap), secondo, la funzione che stai wrappando non viene mai chiamata; andando alla cieca, non conoscendo le vere intenzioni del tuo codice, farei una cosa del genere @is_session_alive def test(request): return 'OK' il deco e' il seguente def is_session_alive(function): def wrap(request, *args, **kwargs): retvals = {'test': function(request, *args, **kwargs} return HttpResponse(retvals) return wrap -- "Unix IS user friendly. It's just selective about who its friend are" "Nevertheless I still think it’s a bad idea to make things harder for ourselves if we can avoid it." "C is quirky, flawed, and an enormous success." -- Dennis Ritchie "Shipping is a feature. A really important feature. Your product must have it." "There is no such a thing as a temporary change or workaround: In most cases, workarounds are tech debt." "La gatta frettolosa ha fatto i gattini ciechi"
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python