Hi I'm trying to add a somewhat transparent cache to certain SQLAlchemy objects in my application. Not a general query cache, just a cache for often used objects with a Memcached backend.
This is all working just as expected with one caveat. After loading an object from the cache I merge it back into the session using session.merge(obj, load=False). If I try to make changes to this object through its attributes I noticed that I never see a flush. That is, for merged objects I need to call flush explicitly. Otherwise zope.sqlalchemy which I use in conjunction with SQLAlchemy won't commit the transaction as it uses a flush event to determine if a transaction has anything to commit. What I find interesting is that objects changed after session.merge(obj, load=*True*) will result in an automatic flush. I'm wondering now if this is intentional and why that would be. I looked through the docs but I can't find anything that explains this behaviour. Also, if there is some specific reason for this I would be interested to find out if I can somehow distinguish objects loaded through load=False from objects loaded through load=True. I've used sqlalchemy.inspect in this regard to no avail. Thanks for your input. Denis -- 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.
