#29607: detailed documentation/cookbook on how to handle files and their
lifecycles
in models
-------------------------------------------+------------------------
Reporter: Thomas Grainger | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
Currently the documentation on how to do various file operations isn't
documented eg:
* I've got some file contents as a string and a model instance with a file
field, I want to set the content of the instances' file to the value of
the string
* I've got a file like object and I'd like to transform it line by line
then append it to the file of a model field.
In all cases:
* properly managing the file lifetime open/close so that it works on non-
reference counting python implementations like PyPy
* cleaning up the FieldFile so that other code that accesses the file
still works
* never using up too much memory by reading a whole file into memory
Also, are some methods like: `instance.file.read()` without an associated
`with instance.file.open()` always dangerous - and should they be
deprecated?
Should the Django File instances operate more like `pathlib.PurePath` ? in
that `.read()` opens the file, reads the content then closes it, and
`.write()` opens the file, writes the file, then closes it.
--
Ticket URL: <https://code.djangoproject.com/ticket/29607>
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/052.2db3f19fd2b8baa37612b2ea7b560afc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.