Hi, thanks for your reply.
I am confused, it is during a delete that I should access the grandparent id of my object. (would if have been a add, I wouldn't be confused) If I do a flush, I actually would expect the ID's to be removed and the object to be completely 'unbound'. (So no linked Ids to Room and House, since the row does not exist anymore) Could you elaborate a bit, or point to some documentation? thanks! On Tuesday, August 22, 2017 at 4:33:08 PM UTC+2, Mike Bayer wrote: > > On Tue, Aug 22, 2017 at 9:57 AM, cecemel <ruiz.fe...@gmail.com > <javascript:>> wrote: > > Hi, > > > > so, I'm currently facing this issue, where I would like to do some calls > to > > an external service, when my object has been deleted within a flush. > > For this operation to occur, I need the id from my model object, but > also > > the id from the parent of the parent object model. There are cases, > where I > > am unable to access them (I guess, depending of the order of the > execution) > > and I am unsure on what to do next. > > if you need auto-generated primary key values to be present, use > session.flush() to ensure it's happened. > > > So my question(s): > > > > Is there a clean way to always acces this parent's parent attribute? > > > > If not, would be starting a new session and query it from the event > handler > > be an option? (is it not dangerous, because it seems to work) > > > > Additional quirk, I am working within a transaction manager (pyramid_tm) > and > > ZopeTransactionExtension() > > assuming things are flushed you should be able to access the object > graph and the various .id attributes fully. session.flush() will get > you there. > > > > > Thanks! > > > > > > More information about the system: > > > > SQLAlchemy 1.1.13 > > > > Python 3.5 > > > > Postgres 9.6 > > > > -- > > 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 sqlalchemy+...@googlegroups.com <javascript:>. > > To post to this group, send email to sqlal...@googlegroups.com > <javascript:>. > > Visit this group at https://groups.google.com/group/sqlalchemy. > > For more options, visit https://groups.google.com/d/optout. > -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.