As expected, when RECORD VERSIONING is enabled, a db record deletion causes 
the RECORD to be archived with all the record contents maintained rather 
than being deleted. 
And if the record is reactivated, all the record contents are restored 

However, if the record has an upload field and autodelete=True  is 
specified, the ACTUAL FILE is deleted. 

In my opinion this produces an inconsistent result. The archived db record 
retains the path - but now to a non-existent file.
if delete() and record_delete() don't mean truly delete, then the 
autodelete shouldn't either

with autodelete
Field('the_file', 'upload'     , label=T('Audio File')
                                         , writable=True
                                         , autodelete=True
                                         , default=None
                                         , 
uploadfolder=os.path.join(request.folder,'uploads/resources/audio')
                ),

and the result of a record delete is...

archive_x2m: archive base_table record = audios[10]

archive_x2m: uploaded audio file path = 
/Applications/web2py_dev/applications/MFMCurrAssetMgr/uploads/resources/audio/audios.the_file.b96db9904e30d353.6131343035323731312e6d7033.mp3

archive_x2m: Does uploaded file exists BEFORE delete_record(), i.e. 
os.path.exists(full_path)? -  True

archive_x2m:   >> execute "db(db.audios.id == record_id).delete()"

archive_x2m: Does uploaded file exist AFTER delete_record(), i.e. 
os.path.exists(full_path)? -  False

archive_x2m: Done !




the following without autodelete...
Field('the_file', 'upload'     , label=T('Audio File')
                                         , writable=True
                                         , default=None
                                         , 
uploadfolder=os.path.join(request.folder,'uploads/resources/audio')

                ),


and the result

archive_x2m: archive base_table record = audios[30]

archive_x2m: uploaded audio file path = 
/Applications/web2py_dev/applications/MFMCurrAssetMgr/uploads/resources/audio/audios.the_file.bd416488d5bffdf5.6131343035323733322e6d7033.mp3

archive_x2m: Does uploaded file exists BEFORE delete_record(), i.e. 
os.path.exists(full_path)? -  True

archive_x2m:   >> execute "db(db.audios.id == record_id).delete()"

archive_x2m: Does uploaded file exist AFTER delete_record(), i.e. 
os.path.exists(full_path)? -  True

archive_x2m: Done !



-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/00f6f338-2294-4878-b918-e15cc5e44888%40googlegroups.com.

Reply via email to