Andrew Channels Dexter Pinion

Wherein I write some stuff that you may like to read. Or not, its up to you really.

May 09, 2002

Seamless Persistent Storage

There is a new release of PythonCard coming out this week, lots of interesting new goodies ...

Meanwhile I'm struggling with a way to come up with transparent persistent storage in an easy to use desktop development environment. The existing flatfileDatabase sample is my starting point. In it Kevin takes a Model-View-Controller approach to storing fairly standard address records in a text file. The storage approach is fairly forceful, it simply saves the current record when you navigate out of it, but it should prove an interesting test bed for integrating other storage mechanisms. Top of my heap are shelve and MySQL.

What I need to do is implement a generic storage mechanism. Inspired by the contents of weblib and bdoz how is this for a first stab at a super class definition;

class Storage:
    def open(self):
        "Initialise this storage object"
    def store(self, table, **row):
        "Store an item"
    def fetch(self, table, id):
        "Fetch an item by its key"
    def find(self, table, where):
        "Find an item by a non-key value"
    def delete(self, table, id):
        "Remove an item permanently"
    def _insert(self, table, **row):
        raise NotImplementedError
    def _update(self, table, **row):
        raise NotImplementedError

The stored items would be passed arounds as dictionaries I think. This makes interfacing with ZODB and shelve quite easy and is quite analagous for us RDBMS types. I think I will let this kick around in my subconscious for a bit before I actually get off my bum and try and implement it.

Posted by Andy Todd at May 09, 2002 05:44 PM