I'm working on a calendering/PIM application, and I have several independent
datasets I need to work with (all in the same MK storage). Can anyone give me
a recipe for generating surrogate key values? Since I'm only allowing one
opener for the storage, I suppose I could get the last key value used by
sorting the view and giving new rows a key value greater than the last value
used, but that doesn't feel like the best solution - I've spent years avoiding
just this kind of thing in SQL...
To make this concrete, here's how it would look in Python:
import metakit as mk
db = mk.storage()
v = db.getas("contact[key:I,name:S,address:S,city:S,state:S,zip:I]")
nextkey = 1
if v:
nextkey = v.sort(v.key)[-1]+1
and then any inserts into the view would use the current value of nextkey and
increment it (all of this is actually in a class that keeps all of the ugly
stuff hidden, so the keeping track part isn't as bad as it looks here).
I don't want to use the row numbers returned when I add a row, because then
I'd be up a creek if I ever deleted a row (which I don't expect to do a lot
of, but I don't want to preclude).
So - is there a better way?
/cco
--
GPG Key Fingerprint: B375 A4E7 752B DB8C 4359 852E C3CF BF64 379A E9B2
Debian Project (http://www.debian.org)
_______________________________________________
metakit mailing list - [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit