On Tue, Aug 22, 2017 at 9:57 AM, cecemel <ruiz.felixr...@gmail.com> 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+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.

-- 
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.

Reply via email to