I have a program with a table that pertains to user avatars. The
'f_user_id' field in the table references user ids, and the table contains
upload fields referring to image files and their corresponding thumbnails.
Running the following function produces an error:
def delete_record_by_user_id(self, user_id):
self.db(self.db.auth_avatar.f_user_id == user_id).delete()
The error is:
...
File "...\web2py\gluon\packages\dal\pydal\objects.py", line 2045, in delete
if any(f(self) for f in table._before_delete): return 0
File "...\web2py\gluon\packages\dal\pydal\objects.py", line 2045, in <genexpr>
if any(f(self) for f in table._before_delete): return 0
File "...\web2py\gluon\packages\dal\pydal\objects.py", line 2137, in
delete_uploaded_files
items[2][:2])
IndexError: list index out of range
The error is generated in the delete_uploaded_files() function in pydal's
objects.py.
Some of the entries in the table were missing file references. Deleting the
entries with the missing files made it possible to use my
'delete_record_by_user_id' function with no errors being generated.
A bug that caused a comparable issue
<https://groups.google.com/forum/#!searchin/web2py/delete$20list$20index$20out$20of$20range/web2py/5W8YCe3XAes/xm__GxMTMe8J>
was found some time ago.
--
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].
For more options, visit https://groups.google.com/d/optout.