flask-sqlalchemy
flask-sqlalchemy copied to clipboard
Implement support for custom sessions
Backwards compatible change to address #327
~~I'm of two minds about the place in the documentation. I was thinking of merging the customizing and configuration pages into one (which is what I should've done in the first place >_>).~~
~~Otherwise, I think this is a straight forward change.~~
Update: Rebased onto master including converting the custom session test to py.test and moved the documentation of custom sessions into the customization sections.
I came here to implement this myself, glad to see it's already been done. LGTM :+1:
Ping @immunda @davidism Have either of you had a chance to review this?
I noticed that the Py3.4 Lowest tests fail on the scopefunc test -- I'm not sure if that is a regression or something flaky that happens. I noticed it happened in a master build a few builds ago.
Also, the TRACK_MODIFICATIONS and unset database URI warnings create a lot of noise in the tests -- did I screw something up with a rebase, it doesn't look like other branches have this issue.
Sorry, I'm really stretched thin and don't have a lot of time to divide between a lot of projects. I need to get back to Flask-SQLAlchemy after I've finished with Flask. Just letting you know that the project's not abandoned, and I will get to this.
Rebased onto latest master again and it looks the errors aren't a thing anymore.
@davidism You brought up in #545 that scoped_session
only proxies public Session methods, however I can't find a location to reference this in the SQLA documentation, am I overlooking something?
I looked at the source: https://bitbucket.org/zzzeek/sqlalchemy/src/2c280791886756422a8103769cf131b0fe292ffe/lib/sqlalchemy/orm/scoping.py?at=master&fileviewer=file-view-default#scoping.py-151:157
def instrument(name):
def do(self, *args, **kwargs):
return getattr(self.registry(), name)(*args, **kwargs)
return do
for meth in Session.public_methods:
setattr(scoped_session, meth, instrument(meth))
At startup, adds proxy methods to scoped_session
only for methods specified in Session.public_methods
.
hm, odd it isn't documented. I'll add a warning to the docs tomorrow then. It's there anything else that needs updating with this PR? Should it still target a 3.0 release?
@davidism poke. Is there still interest in merging this PR?
I believe this is related to #438.
@davidism any news on if this will get merged up or needs updated in any way? This functionality would be incredibly useful.
Fixed in #1087