From f98727ee31486e7a468fb3c20cb4d99c71972a53 Mon Sep 17 00:00:00 2001 From: Anatoly Bubenkov Date: Wed, 5 Mar 2014 02:56:10 +0100 Subject: [PATCH] version schema changed --- CHANGES.rst | 4 ++-- setup.py | 2 +- tests/test_i18n.py | 9 +++++++++ traduki/sqla.py | 6 +++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 4bd8169..464e068 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,7 +2,7 @@ Changelog ========= -0.1 ---- +1.0.0 +----- * Initial public release diff --git a/setup.py b/setup.py index dde2393..4cc7f08 100755 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ def run_tests(self): name='traduki', description='SQLAlchemy internationalisation', long_description='\n'.join(long_description), - version='0.1', + version='1.0.0', author='Paylogic International', author_email='developers@paylogic.com', license='MIT', diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 61676fd..a099a29 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -93,3 +93,12 @@ def test_i18n_field(query, model, session): assert model.title.get_dict() == {'en': 'En Title', 'pt': 'Pt Title'} assert model.title.get_text() == 'En Title' + + +def test_class_custom_table(languages): + """Test initialization with custom table.""" + Base = declarative_base() + + traduki.initialize(Base, languages, lambda: 'en', lambda: {}, attributes={'__tablename__': 'custom_table'}) + + assert traduki.sqla.Translation.__tablename__ == 'custom_table' diff --git a/traduki/sqla.py b/traduki/sqla.py index 5e2f2bc..3032485 100644 --- a/traduki/sqla.py +++ b/traduki/sqla.py @@ -36,7 +36,7 @@ def get_dict(self): def get_text(self, code=None, chain=None): """Get the text for specified language code. - Delegates to :py:func:`traduki.helpers.get_text_from_dict`, with all the given arguments and + Delegates to :py:func:`LocalizedString.get_text_from_dict`, with all the given arguments and a dictionary, representing this :py:class:`Translation`. The dictionary is created using :py:func:`get_dict`. @@ -106,7 +106,7 @@ def _do_compare(self, op, other, escape): Looking into the the next language if the given language is not filled in. """ related = self.property.mapper.class_ - cols = [getattr(related, lang) for lang in helpers.get_ordered_languages() if hasattr(related, lang)] + cols = [getattr(related, lang) for lang in helpers.ordered_languages() if hasattr(related, lang)] return self.has(op(func.coalesce(*cols), other, escape=escape)) @@ -137,7 +137,7 @@ def set(state, value, oldvalue, initiator): if oldvalue is None: return Translation(**value_dict) else: - for lang in helpers.get_ordered_languages(): + for lang in helpers.ordered_languages(): setattr(oldvalue, lang, value_dict.get(lang)) return oldvalue