X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/a1cdf50e2d333aee2267af6987dc1cf468fbc160..00e0bf75c998b9d9c743d383f1596c91f9a03766:/pokedex/db/__init__.py diff --git a/pokedex/db/__init__.py b/pokedex/db/__init__.py index 140994b..ae06c1b 100644 --- a/pokedex/db/__init__.py +++ b/pokedex/db/__init__.py @@ -1,10 +1,10 @@ # encoding: utf-8 import re -from sqlalchemy import MetaData, Table, engine_from_config, orm +from sqlalchemy import engine_from_config, orm from ..defaults import get_default_db_uri -from .tables import metadata +from .tables import Language, metadata from .multilang import MultilangSession, MultilangScopedSession @@ -44,9 +44,15 @@ def connect(uri=None, session_args={}, engine_args={}, engine_prefix=''): all_session_args = dict(autoflush=True, autocommit=False, bind=engine) all_session_args.update(session_args) - sm = orm.sessionmaker(class_=MultilangSession, **all_session_args) + sm = orm.sessionmaker(class_=MultilangSession, language_class=Language, + **all_session_args) session = MultilangScopedSession(sm) + # Default to English. Warning, magic constant, blah blah. Trying to fetch + # English here would kinda break on new databases. TODO still not an ideal + # solution, I guess. + session._default_language_id = 9 + return session def identifier_from_name(name):