Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor patch_session() into more something more generally useful #71

Open
RobRuana opened this issue Mar 18, 2017 · 1 comment
Open

Comments

@RobRuana
Copy link
Contributor

patch_session() looks like a code smell, so we should eventually refactor it. However, I'm marking this issue as low-priority because MAGFest won't derive any immediate value from fixing it.

@EliAndrewC
Copy link
Contributor

The implementation is indeed wonky; I doubt that monkeypatching the session instance is anywhere close to the best way to provide that kind of functionality.

I was basically trying to do stuff like this:
https://docs.djangoproject.com/en/1.10/topics/db/managers/#adding-extra-manager-methods

At the time I wasn't able to figure out a more supported way of doing it. Re-reading through the docs a bit, I think the correct approach is to subclass Session and then pass that as the class_ parameter to sessionmaker:
http://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.sessionmaker.__init__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants