Chapter 10. Storing and Retrieving Objects via Shelve
There are many applications where we need to persist objects individually. The techniques we looked at in Chapter 9, Serializing and Saving – JSON, YAML, Pickle, CSV, and XML, were biased towards handling a single object. Sometimes, we need to persist separate, individual objects from a larger domain.
Applications with persistent objects may demonstrate four use cases, summarized as the CRUD Operations: Create, Retrieve, Update, and Delete. In the general case, any of these operations may be applied to any object in the domain; this leads to the need for a more sophisticated persistence mechanism than a monolithic load or dump to a file. In addition to squandering memory, simple loads and dumps are often less efficient than fine-grained, object-by-object storage.
Using more sophisticated storage will lead us to look more closely at the allocation of responsibility. The various concerns give us overall design patterns for the architecture...