#18283: FileField should not reuse FieldFiles
-------------------------------------+-------------------------------------
Reporter: sayane | Owner: trg
Type: Bug | Status: assigned
Component: Database layer | Version: 1.4
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by trg):
I have a real trouble with reproducing this bug. The description of it is
very enigmatic - the submitter didn't mention what
`do_something_with_image()` actually does (for instance, what type of
object it returns).
This bug seems to happen only when one takes the `FieldFile` object from
specified model field and modifies it in place. This is illustrated by
`test_unchanged_fieldfile` in the diff below:
https://github.com/django/django/compare/master...szopu:ticket_18283?expand=1
The only way I see this problem can be fixed, is defensive shallow copying
of the `FieldFile` object in `__get__` and `__set__` (I think that doing
it for `__set__` only is not enough). But this solution has a downside,
for instance, this would generate following semantics:
{{{#!python
model.myfile.name = 'somefile.txt'
print(model.myfile.name) # returns the previous filename instead of
'somefile.txt'
}}}
So my question is: Is it the right way to go?
--
Ticket URL: <https://code.djangoproject.com/ticket/18283#comment:4>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.43b9ca7755e4b3b53f94fece7c25db9f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.