#13809: FileField open method is only accepting 'rb' modes
-------------------------------------------+--------------------------------
Reporter: canassa | Owner: nobody
Status: reopened | Milestone:
Component: File uploads/storage | Version: 1.2
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by jesh):
* status: closed => reopened
* resolution: invalid =>
Comment:
This still does not work for me. Documented open() does not honor mode
(it's not *reopening* r/o file). That has a annoying side effect, so that
FieldFile.file.open("w") does not work. This is because _get_file has
already opened it as read only. As a workaround, every open could be
preceded by lonely close(), but IMHO that's just plain ugly. My app code
looks like
{{{
class MyModel(models.Model:
file = models.FileField(...)
this does not work:
f=mymodel.file.open("rw")
mymodel.file.write(content) # -> invalid fd
mymodel.file.close()
this will work:
f=mymodel.file # file gets opened here, see [1]
f.file.close() # following open [2] uses "rb" without this -> invalid fd
when writing
f.file.open("wb")
mymodel.file.write(content)
mymodel.file.close()
}}}
1.
http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/files.py#L49
2.
http://code.djangoproject.com/browser/django/trunk/django/core/files/base.py#L110
--
Ticket URL: <http://code.djangoproject.com/ticket/13809#comment:2>
Django <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.