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

pokemaster.pokemon.Pokemon should not bind to a session #1

Closed
kipyin opened this issue Jan 4, 2019 · 2 comments
Closed

pokemaster.pokemon.Pokemon should not bind to a session #1

kipyin opened this issue Jan 4, 2019 · 2 comments
Labels
feature New feature or request

Comments

@kipyin
Copy link
Owner

kipyin commented Jan 4, 2019

@attr.s(auto_attribs=True, repr=False, cmp=False)
class Pokemon:
"""A Pokémon."""
session: ClassVar = get_session()

Binding a pokemaster.pokemon.Pokemon object to a db session couples the class with a db schema, and having them completely separated is much preferred.

But if we remove this class var, how can properly instantiate a pokemaster.pokemon.Pokemon instance?

E.g., how do we get the correct database for the following helper class method?

species = util.get(cls.session, tb.PokemonSpecies, id=species_id)

@kipyin
Copy link
Owner Author

kipyin commented Jan 4, 2019

I think, we should keep all the database mess in pokemaster.query module, including the (only) function, pokemaster.session.get_session(). If we need to change the db, use pokemaster.query.bind_session().

@kipyin kipyin changed the title Pokemon class should not bind to a session pokemaster.pokemon.Pokemon should not bind to a session Jan 4, 2019
@kipyin kipyin added the feature New feature or request label Jan 4, 2019
@kipyin
Copy link
Owner Author

kipyin commented Jan 14, 2019

Fixed in dae9187

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

No branches or pull requests

1 participant