[sqlalchemy] preserve polymorphic_identity for subclasses

2015-06-29 Thread Burak Arslan
hello, here's a test case: https://gist.github.com/plq/5ed0c135222ea76d77fc (also see below) is it possible to preserve the polymorphic_identity values of subclasses that contain changes to non-sqla parts of a class? I understand that the reason for this is D2.__mapper__.class_ != D2. Is there

[sqlalchemy] Using a backref-generated attribute in an event listener

2015-06-29 Thread Adrian
I tried this code: @listens_for(AttachmentFolder.all_attachments, 'append') def _attachment_added(target, value, *unused): target.modified_dt = now_utc() However AttachmentFolder.all_attachments is a backref so it doesn't exist at import time (I usually register listeners right after the

Re: [sqlalchemy] Using a backref-generated attribute in an event listener

2015-06-29 Thread Mike Bayer
On 6/29/15 5:37 AM, Adrian wrote: I tried this code: @listens_for(AttachmentFolder.all_attachments, 'append') def _attachment_added(target, value, *unused): target.modified_dt = now_utc() However AttachmentFolder.all_attachments is a backref so it doesn't exist at import time (I usually

Re: [sqlalchemy] preserve polymorphic_identity for subclasses

2015-06-29 Thread Mike Bayer
On 6/29/15 8:47 AM, Burak Arslan wrote: hello, here's a test case: https://gist.github.com/plq/5ed0c135222ea76d77fc (also see below) is it possible to preserve the polymorphic_identity values of subclasses that contain changes to non-sqla parts of a class? I understand that the reason

[sqlalchemy] how to recycle connections grown stale after checkout

2015-06-29 Thread Andy Crain
Hi, What is the best way to forcefully/manually “recycle” a checked out connection that I know to have become stale since it was checked out? And by stale, I mean this is a MySQL connection that has idled beyond MySQL’s wait_timeout (triggering a MySQL has gone away error when it's

Re: [sqlalchemy] how to recycle connections grown stale after checkout

2015-06-29 Thread Andy Crain
Michael, Thanks very much. This helps. I'm using InnoDB without autocommit. The reason for the odd, long-idling connection is that I'm actually using Flask-SQLAlchemy, and the long-idling connection is held by Flask-SQLAlchemy's primary, request-scoped session. I do some long-running,

[sqlalchemy] Re: how to recycle connections grown stale after checkout

2015-06-29 Thread Andy Crain
Jonathan, Thanks, but I'm attempting to deal with connections that have expired *after* checkout. The strategies discussed at that URL address freshness of connections upon checkout. From that page: Note that the invalidation *only* occurs during checkout - not on any connections that are

Re: [sqlalchemy] how to recycle connections grown stale after checkout

2015-06-29 Thread Mike Bayer
On 6/29/15 2:33 PM, Andy Crain wrote: But these seem heavy handed and wrong. What I’d like to do is just discard this stale connection (in my session and in the pool) and get a fresh one, but I can’t determine how to. at the bottom of that section, the important part is about

[sqlalchemy] Re: how to recycle connections grown stale after checkout

2015-06-29 Thread Jonathan Vanasco
http://docs.sqlalchemy.org/en/latest/core/pooling.html#dealing-with-disconnects -- 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