I have a pretty simple goal, so simple I probably don't even need example code.
I have 2 classes, and I want to pull the identity key from an instance of one class, and use the values to create an instance of the second, without requiring (or introspecting) things like the PK names, FK names linking them, etc. Something like:
instance1 = Class1()
cls, vals = identity_key(instance=instance1)
instance2 = Class2.from_identity_key(vals) # that method doesn't exist
I am trying to do this without requiring any of the PK column names or FK info linking the 2 tables together (they are a 1-to-1 relationship). given only an instance of Class1 and the class "Class2", I want to create the instance of Class2.
Is this possible? Is there a way to "reverse" identity_key, so instead of instance -> (cls, vals) I could do (cls, vals) -> instance?
JT