#8912: File storage and save/commit=False
---------------------------------------------+------------------------------
Reporter: shadfc | Owner: shadfc
Status: assigned | Milestone:
Component: File uploads/storage | Version: 1.0
Resolution: | Keywords:
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
---------------------------------------------+------------------------------
Changes (by shadfc):
* status: new => assigned
* needs_tests: 0 => 1
* summary: Filestorage backend doesn't get "save" argument => File
storage and save/commit=False
* owner: nobody => shadfc
* has_patch: 0 => 1
* stage: Unreviewed => Design decision needed
Comment:
The attached patch basically just propagates the save argument in
FieldFile.save() into storage.save() and then into storage._save(). This
gives the custom backend designer control of the behavior.
Looking at what happens in storage.save() raised a few questions as to my
approach. The call to storage.save() in FieldFile.save() expects the name
of the saved file to be returned. So, if the backend gets a save=False
argument and doesn't actually save the file, what should it return? It
could just generate the expected filename -- the name it would have saved
the content to, but that has no guarantee that when it really does save to
the backend that that name is still available.
Should a save=False on FieldFile.save() just not call the stoarge.save()
and set the FieldFile's name to something non-definite ('unsaved file')?
Also, I was just looking at FieldFile.delete() and saw that it has the
same problem -- the storage.delete() call is not dependent on save=True
and will always happen.
Input from people smarter than me would be welcome on whether I am wrong
about all of this.
--
Ticket URL: <http://code.djangoproject.com/ticket/8912#comment:3>
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---