That was my first thought: in some cases, another request deletes the 
record right in the instant between the execution of the first and second 
line.
But I thought it wasn't possible because the function runs inside a db 
transaction. Or could it still happen? 

Another thought is that the row.id is removed or set to None by 
row.update_record(**data), so the next line would set row to None, thus 
triggering the error.
But I'm not sure how could that happen. I checked and the "data" dictionary 
hasn't got the "id" key (I mean, the id field isn't updated).

Anyway, what I'm going to do to catch the error is this:

row.update_record(**data)
if not row:
    return response.json({'success':False})
row.update_tsv()

This way I'll avoid the error ticket for those few cases.
I guess I could also decompile a couple of apps and put a log line there, 
though I don't know exactly what to log.



El jueves, 19 de julio de 2018, 10:56:55 (UTC-3), Anthony escribió:
>
> On Thursday, July 19, 2018 at 4:26:09 AM UTC-4, Lisandro wrote:
>>
>> Well, I owe you an apology, because I got confused regarding which app 
>> was throwing the error and which web2py version was running. 
>>
>> Until recently, I was using a very old web2py version (2.10). This 
>> problem was happening since long time ago (but not very frequently as I 
>> stated). For that old web2py version, I had already applied the fix to my 
>> app:
>>
>> row.update_record(**data)
>> row = db.content[row.id]
>> row.update_tsv()
>>
>
> There must still be something else going on that we're not seeing. Even in 
> web2py 2.10, there would have been no way to get the error in question, as 
> the .update_record method could not turn a Row object into None.
>
> I suppose the above code could generate this error if the record in 
> question could be deleted in a separate HTTP request in between the 
> execution of the first and second lines above. Is that possible (i.e., is 
> there some other action that could be deleting existing records)?
>
> Anthony
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to