Stuart 'Zen' Bishop wrote:
Have you seen my How-To on generating Unique ids? It may not be _exactly_ what you are looking for, but it will provide a decent starting place.
But What happens when two ID's are generated at exactly the same time through different threads?
ZODB will not allow two persistent objects to be overwriten at the same time.
So an object can simply have an integer counter that is incremented as necessary, and if two threads try to modify the counter at about the same time, the one that tries to commit last will rollback and be reexecuted. If this is true, its so trivial a counter class and locking is totally unnecessary :-) And it should work with ZEO as well from what I understand of its architecture.
Yep. Because it's persistent however, every unique id will cause a transaction, in a ZEO environment, this would cause lots of object colisions over the wire. Probably not very scalable. ZODB has a lot of potention for non version-based storages however, we are currently working on an projecy oriented toward just that. -Michel