[Grok-dev] ZODB and storing, retrieving, deleting, use of ID

Laurence Rowe l at lrowe.co.uk
Sat Oct 4 17:57:44 EDT 2008


John de la Garza wrote:
> I'm making an app that has polls for voting... When I make a Poll  
> object to I have to create an ID so I can find it again.  I'm comming  
> froma RDBMS background and am wondering if there are any articles  
> that would helpl me transistion.  For example should the ID be the  
> last object id + 1?  I saw some sample code that kept the objects in  
> a list then just got the length of the list, but if items are deleted  
> then using the len as the ID could be trouble (not unique).... any  
> feed back would be apprecitated.  I've read intro to ZODB (Jim  
> Fulton) but it doesn't mention deleting

* Randomised keys have better efficiency when filling a B-Tree. You need 
to check that the randomly generated key does not already exist.

* Store the length with a BTrees.Length.Length and increment/decrement 
as you add/delete.

Laurence



More information about the Grok-dev mailing list