Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.pyc
*.pyo
*.orig
.env
/.tox
/bin
/include
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: python
# command to install dependencies
install:
- pip install python-coveralls virtualenv
- pip install tox
# # command to run tests
script: python setup.py test
script: tox
after_success:
- pip install -r requirements-testing.txt -e .
- py.test --cov=traduki --cov-report=term-missing tests
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Unreleased
----------

* Use index=True when declaring language columns to be able to search efficiently on language fields.
* Mark object with the translation property as modified when the property setter is called (bubenkoff)

1.0.0
-----
Expand Down
10 changes: 8 additions & 2 deletions traduki/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""Configuration for i18n."""

LANGUAGE_CALLBACK = lambda: 'en'

LANGUAGE_CHAIN_CALLBACK = lambda: {'*': LANGUAGE_CALLBACK()}
def LANGUAGE_CALLBACK():
"""Current language callback."""
return 'en'


def LANGUAGE_CHAIN_CALLBACK():
"""Language chain callback."""
return {'*': LANGUAGE_CALLBACK()}

LANGUAGES = ['en']
4 changes: 4 additions & 0 deletions traduki/sqla.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

from sqlalchemy import Column, Integer, ForeignKey, UnicodeText
from sqlalchemy.exc import ArgumentError
from sqlalchemy.inspection import inspect
from sqlalchemy.orm import relationship
from sqlalchemy.orm.attributes import flag_modified
from sqlalchemy.orm.interfaces import AttributeExtension
from sqlalchemy.orm.properties import RelationshipProperty
from sqlalchemy.sql import operators as oper, functions as func
Expand Down Expand Up @@ -134,6 +136,8 @@ def set(state, value, oldvalue, initiator):
:param oldvalue: The current value.
:param initiator: SQLAlchemy initiator (accessor).
"""
if state._strong_obj is not None:
flag_modified(state._strong_obj, inspect(state._strong_obj.__class__).primary_key[0].name)
if value is None:
return None

Expand Down