Hi there! I'm having this weird issue where, after doing a 
row.update_record(), the row object ends up being None.

The scenario is simple: it is a function that receives a post with some 
data, creates a dictionary with the data, updates de row, and finally calls 
a virtual method of the row.
This is the function, simplified:

def edit():
    row = db.content[request.args(0)]
    data = {
      'name': request.vars.name,
      'age': request.vars.age
    }
    row.update_record(**data)
    row.update_tsv()
    return 'done!'


This function is executed several times per day (about 1.000 times in an 
average day). 
But the function throws error about 3 or 4 times per day, and this is the 
error:

AttributeError: 'NoneType' object has no attribute 'update_tsv'



I can't reproduce it, because as I said, the function works ok and is 
executed several times per day. Still, I can't figure out what could be 
causing those isolated errors. 
If the whole function is executed inside a db transaction, what could be 
the reason why row object ends up being None after running update_record?


I was able to avoid those isolated errors with this fix:

row.update_record(**data)
row = db.content[request.args(0)]
row.update_tsv()

I could even prevent those errors whit this fix:

row.update_record(**data)
row = db.content[row.id]
row.update_tsv()

That's weird. But also I don't think that is the proper solution: it's 
inefficient, and I would have to add that extra select in every single line 
where my app calls .update_record(), obviously that's ugly and I've 
discarded the solution.

So, what could be causing the error?
Any help or comment will be much appreciated.
I'm using last stable version of web2py 
(2.16.1-stable+timestamp.2017.11.14.05.54.25)

Best regards,
Lisandro.

-- 
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