Hi Dave,
thanks for the reply, but I have notice that the code is wrong, I will
explain.
Since I need three function in task I used another one to collector and
after I redirect by an if statement.
So I have the funtion: my_task(func, filtri, *argv) and the function
produzione(dbnow, filtri, *argv).
In the example I have synthesized the by putting only one function.
The correct one that I have test a lot of time is:
def produzione(dbnow, filtri, *argv):
object_list = []
if filtri == 0:
rows = dbnow(dbnow.Produzione.ID != None).select()
else:
data1 = fixDate(argv[Filter.DataIn.value])
data2 = fixDate(argv[Filter.DataFin.value])
rows = dbnow((dbnow.Produzione.OraInizio >= data1)&(dbnow.Produzione
.OraInizio <= data2)&(dbnow.Produzione.Macchina == argv[Filter.IdMac.value
])).select()
for record in rows:
d = collections.OrderedDict()
d['ID'] = record.ID
d['DataLoggerID'] = record.DataLoggerID
d['DataLoggerIDRiga'] = record.DataLoggerIDRiga
d['Utente'] = record.Utente if (record.Utente != None) else 0
d['Commessa'] = str(record.Commessa)
d['Lotto'] = str(record.Lotto)
d['Fase'] = record.Fase if (record.Fase != None) else 0
d['Programma'] = str(record.Programma)
d['OraInizio'] = str(record.OraInizio)
d['OraProgrammazione'] = str(record.OraProgrammazione)
d['OraAttrezzaggio'] = str(record.OraAttrezzaggio)
d['OraPrimoPezzo'] = str(record.OraPrimoPezzo)
d['OraProduzione'] = str(record.OraProduzione)
d['OraFine'] = str(record.OraFine)
d['NPieghe'] = record.NPieghe if (record.NPieghe != None) else 0
d['Macchina'] = record.Macchina if (record.Macchina != None) else 0
d['PezziProdotti'] = record.PezziProdotti if (record.PezziProdotti
!= None) else 0
object_list.append(d)
return json.dumps(return object_list)
Moreover if I run the request for a Browser and I can see the right result.
I hope I was clear in the explanation
Edoardo Torrini
Il giorno martedì 25 febbraio 2020 07:36:15 UTC+1, Dave S ha scritto:
>
>
>
> On Sunday, February 23, 2020 at 11:26:50 PM UTC-8, Edoardo Torrini wrote:
>>
>> Hi,
>> I will attach you some part of code:
>>
>>
>>
>>
>> this is the task of my app:
>>
>> [image: task prd - py4web.png]
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> I am still surprised by that last line.
>>
>
> Wouldn't the return exit produzione() while evaluating object_list and
> before actually calling the json.dumps() ?
>
> /dps
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/066365ac-d359-4224-9a40-7642eacfcabf%40googlegroups.com.