Hello all, I've stumbled across a strange problem with some files being deleted when there's been no call to do so. The issue comes across during a callback that modifies the 'position_number' field (shown below).
The model setup (for the table in question) is given by: db.define_table('user_profile_images', Field('user_id','reference auth_user'), Field('user_pic',type='upload',autodelete=True), Field('picture_size',type='float'), Field('user_pic_thumb',type='upload',autodelete=True), Field('thumb_size',type='float'), Field('position_number',type='integer')) from images import THUMB db.user_profile_images.user_pic_thumb.compute = lambda row: THUMB(row.user_pic, 200, 200) The callback: @auth.requires_login() def delete_pic(): to_del = request.args(0,cast=int) pic = db(db.user_profile_images.id == to_del).select().first() if pic.user_id == auth.user.id: db(db.user_profile_images.id == to_del).delete() re_order = db((db.user_profile_images.user_id == auth.user.id) & (db.user_profile_images.position_number > pic.position_number)).select() for img in re_order: current_position = img.position_number img.update_record(position_number = current_position - 1) Every row inside of re_order is having it's thumbnail deleted (physically removed from the uploads folder) as the loop runs. Aside from the correct update to current_position, the database is otherwise unchanged and the main picture (user_pic as described by the model) remains in place. After playing with things for a while, I noticed that if the update inside of the for loop is changed to: for img in re_order: current_position = img.position_number img.position_number = current_position - 1 img.update_record() then everything works as expected, and there is no accidental deletion of thumbnails. Why would the initial loop delete the thumbnail, and this modified code run as expected? -- 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.