On Saturday, March 17, 2018 at 9:29:49 AM UTC-4, Mike Bayer wrote:
>
> this is the usual, "do it in the __init__() method" or "use the init() 
> event" approach.    Plenty of ways to intercept when an object is 
> "generated" (which in this case I assume means instantiated as 
> transient). 
>


Thanks. I didn't think of that.  A "new transient object" is the correct 
assumption.

The temporary code has "grown" to something like this...

    # A has the id
    objA = ClassA()
    dbSession.add(objA)
    dbSession.flush(objects=[objA, ])

    objB = ClassB()
    objB.id = objA.id
    dbSession.add(objB)
    dbSession.flush(objects=[objB, ])

    objC = ClassC()
    objC.id = objA.id
    dbSession.add(objC)
    dbSession.flush(objects=[objC, ])

    objD = ClassD()
    objD.id = objA.id
    dbSession.add(objD)
    dbSession.flush(objects=[objD, ])

As you can see, there's a lot of housekeeping to do.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to