#8912: Filestorage backend interface for save() should accept save/commit 
argument
----------------------------------+-----------------------------------------
 Reporter:  shadfc                |       Owner:  nobody    
   Status:  new                   |   Milestone:            
Component:  File uploads/storage  |     Version:  1.0       
 Keywords:                        |       Stage:  Unreviewed
Has_patch:  0                     |  
----------------------------------+-----------------------------------------
 Background:  I noticed this when playing with save_formset() on ModelAdmin
 in order to modify the data for a FileField on an inline model before it
 gets sent to S3 via a custom filestorage backend.

 In admin.py
 {{{
     def save_formset(self, request, form, formset, change):
         instances = formset.save(commit=False)
         for instance in instances:
             if not instance.id:
                 raise Exception('testing file creation')
             instance.save()
         formset.save_m2m()
 }}}

 Now, when saving a new inline instance which has a file field, the
 exception is raised before that instance gets save()'d.  I kept noticing,
 however, that I would still get the full uploaded file with the proper
 name in my S3 account.  So, I raised an exception in the _save() on my
 custom backend and walked it back to the formset.save(commit=False) call.

 It seems to me that the commit=False should keep file writes from
 happening; it doesn't.  Looking in django/db/models/fields/files.py, the
 save() takes a save argument but doesn't use it when dealing with the save
 call to the storage backend. If the argument was passed along to the save
 on the storage backend, then it could decide whether or not to actually
 write the file.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8912>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to