auto increment:

Here's one way

   class Sequence(Persistence):
       def __init__(self):
           self.current = 0

       def next(self):
           self.current += 1
           return self.current

   ticketSequence = Sequence()

   class Ticket(Persistence):
       def __init__(self):
           self.id = ticketSequence.next()


I am sorry, but this does not work if several threads or processes
try to get a new id.

Have a look at:
http://www.zope.org/Documentation/Books/ZDG/current/Persistence.stx
"Resolving Conflicts".

BTW, that's one of the points why I switched from ZODB to Postgres.

 HTH,
   Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to