Hi all, I have a mapper that looks like this:

mapper( Registration, registration_table, properties={
    'purchase': relation(Purchase, 
backref=backref('registration', uselist=False), 
        cascade='all' ),
})

My registration table has a foreign key to purchases, and I want to make
sure no registration exists without an associated purchase. I have the
referrence backwards like a many-to-one because purchases may also be
referred to in other tables ( like memberships ). Maybe this is not a
good idea, not sure. Feel free to tell me. Should this perhaps be
handled in a separate associating table with primary key with one column
primary key constraints on it?

But, my immediate problem is that I don't know what the correct way to
make sure I create a purchase on creation of a registration. Should I be
creating a purchase in the registration constructor? Should I be doing
something like:

r = Registration( purchase=Purchase() )

Or should it work magically if I set up my cascade options differently?

Thanks
Iain



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to