Trying ZODB, background in Relational: mimic auto_increment?

P

Phillip B Oldham

Hi all. I'm playing with standalone ZODB at the moment trying to get a
better understanding of its use in applications. I come from a
PHP/MySQL background, and I'm taking my first steps with Python at the
same time.

One of the things I'm not understanding about ZODB is assigning
incremental IDs to objects. For instance, if I were to be writing a
support-ticket system I'd want to give each ticket a unique number,
but one that's "human-useable" (otherwise you could just use a UUID -
try giving one of those over the phone!).

Also, how would one add a new item to the db in this way?

For instance:

class Ticket(Persistence):
def __init__(self):
self.id = '' # How do I add a new incremental ID here?

# and later on in the app

tkt = Ticket()
dbroot[?????] = tkt

How would one assign a unique ID to the root at that point?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top