Make it easier to play: add TempFileStore
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
FileStore |
Fix Released
|
High
|
Jason Gerard DeRose |
Bug Description
Long ago, before filestore was split out of Dmedia, a FileStore would automatically create a temporary directory if you didn't provide *parentdir*. In the end this was a bad idea for something like FileStore where we need the API to be very explicit, never to make creative guesses about anything.
But my heart was in the right place: you should be able to play with a FileStore with very low friction, without commitment, without risk of damaging production data. So I'm adding a TempFileStore class, inspired by the TempCouch class that has been so useful in usercouch.
I didn't like this because there are lots of scenarios that could cause *parentdir* to be None without the user meaning "please create me a temporary parentdir":
>>> fs = FileStore(None)
But this I do like, because it's unambiguous:
>>> fs = TempFileStore()
Also, because there isn't ambiguity, it's safe to automatically delete the temporary *parentdir* when the TempFileStore is garbage collected. Which is good for play, I think... by definition it will be throw-away.
Related branches
- James Raymond: Approve
-
Diff: 188 lines (+132/-1)4 files modifieddoc/filestore.rst (+40/-0)
doc/tutorial.rst (+13/-0)
filestore.py (+50/-0)
test_filestore.py (+29/-1)
Changed in filestore: | |
status: | In Progress → Fix Committed |
Changed in filestore: | |
status: | Fix Committed → Fix Released |