interface versioned dictionary
i have an versioned request store i wish opening by an dict interface.
common use opening latest supplement (get, set, del), nonetheless should means opening specific revisions too (keys always str/unicode int).
from userdict import dictmixin
class vdict(dictmixin):
def __getitem__(self, key):
isinstance(key, tuple):
docid, rev = key
else:
docid = key
rev = zero # set tip rev
imitation docid, rev
# relapse ...
in [1]: d = vdict()
in [2]: d[2]
2 none
in [3]: d[2, 1]
2 1
this fortitude small bit machiavellian i'm certain clean, graphic interface. should i yield duty
def getrev(self, docid, rev):
...
instead?
Comments
Post a Comment