#4339: Override an existing file, using Model.save_FIELD_file method,
---------------------------------------------+------------------------------
Reporter: [EMAIL PROTECTED] | Owner: Gulopine
Status: reopened | Milestone: 1.0 beta
Component: Database wrapper | Version: SVN
Resolution: | Keywords: FileField db
fs-rf-docs
Stage: Design decision needed | Has_patch: 1
Needs_docs: 1 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by [EMAIL PROTECTED]):
* status: closed => reopened
* resolution: wontfix =>
Comment:
I'm re-opening this because I respectfully disagree with Marty. Don't get
me wrong, I much prefer the new FileStorage backend interface, but
according to the current docs -
[http://docs.djangoproject.com/en/dev/howto/custom-file-storage/#howto-
custom-file-storage 1] the file storage object is never given any context
with which to decide whether or not to overwrite the file.
Here is my dilemna, I have an Image model, that allows customers to upload
images. Inevitably, the customers want to replace a specific image with a
new one, so they re-upload a new version of the file and it gets a new
name. So things break, like CSS background image urls. etc. In the old
monkey-patch, I could query the models to find out if the current model-
instance was the only row that referred to the image, and if so it would
overwrite it. If not, it would rename the file as normal.
With the current system, my custom storage instance has no access to the
necessary request specific context, like model-instance in order to decide
whether or not to overwrite the file. So it must generally make a
decision of "always overwrite files even when they have the same name" or
"always generate a new name, even if the old filename will be orphaned (no
more references to it in the database.)"
--
Ticket URL: <http://code.djangoproject.com/ticket/4339#comment:19>
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
-~----------~----~----~----~------~----~------~--~---