Unique ID generation with ZODB.
How does one implement a unique id generator in ZODB. The id's should be strictyl ascending and be a an int. Would opening a temporary connection increment a persistent counter and commit do the trick?
The simplest solution is to keep the counter as file in the filesystem. Access to the file must be synchronized through a lock object (-> Python docs). Just a few lines of Python code. -aj --On Montag, 5. April 2004 14:18 Uhr +0200 Syver Enstad <syver@inout.no> wrote:
How does one implement a unique id generator in ZODB. The id's should be strictyl ascending and be a an int. Would opening a temporary connection increment a persistent counter and commit do the trick?
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Andreas Jung <andreas@andreas-jung.com> writes:
The simplest solution is to keep the counter as file in the filesystem. Access to the file must be synchronized through a lock object (-> Python docs). Just a few lines of Python code.
It has to work in windows too, so it's a bit more involved but should be manageable with win32all. I don't particularely like that I have another piece of data to backup though.
On 05 Apr 2004 14:18:25 +0200 Syver Enstad <syver@inout.no> wrote:
How does one implement a unique id generator in ZODB. The id's should be strictyl ascending and be a an int. Would opening a temporary connection increment a persistent counter and commit do the trick?
Why does it need to be ascending? If you remove that requirement it makes it nearly trivial to implement. -Casey
participants (3)
-
Andreas Jung -
Casey Duncan -
Syver Enstad