Hmm well I ended up figuring out I can call DBSession.expunge(instance) to 
prevent the instance from trying to reload it's attributes down the road. 

In this case I don't need SQLA to make sure it hasn't been expired, so I'd 
rather just disable the SQLAlchemy state tracking for the life of the 
instance.


On Wednesday, October 21, 2015 at 4:11:32 PM UTC-5, Josh Jaques wrote:
>
> Hey I'm getting some intermittent ObjectDeletedError's that I don't really 
> understand.
>
>
> The code I use looks like this:
>
>
>> DBSession.begin()
>> instance = DBSession.query(OrmOjbect).get("primary_key")
>> DBSession.rollback()
>>
>> ....
>> x = instance.attribute1
>
>
>
>
>
>
> Probably 90% of the time the request for the attribute on the instance 
> works, but the other 10% of the time I'm getting ObjectDeletedError.
> I tried setting expire_on_commit=False for the session to make sure it 
> doesn't get erased from the rollback, but still not sure.
>
> Does it not load those attributes immediately when I run the get()? Is 
> there anyway I can?
> In this case I haveno concern about refreshing attribute1 later in the 
> code.
>

-- 
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to