google-code-export / django-modeltranslation

Automatically exported from code.google.com/p/django-modeltranslation
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add sync_translation_fields #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I'm switching from django-transmeta and found handy the sync_transmeta_fields 
command that allows automatic detection and altering of database when adding 
languages.
So, based on transmeta's command, i've built a similar command: 
sync_translation_fields.
Here is the patch : 
https://github.com/hyperweek/django-modeltranslation/commit/91efab947f0c71fa5946
195254cae2e5217bd46d
Regards,

Original issue reported on code.google.com by sebast...@hyperweek.com on 27 Jun 2011 at 3:11

GoogleCodeExporter commented 9 years ago
Obviously the patch is for another issue. I suppose you mean this one instead?
https://github.com/hyperweek/django-modeltranslation/commit/f49a4ee229031aab2cd4
e549b26198f0c758761d

Original comment by eschler on 28 Jun 2011 at 9:12

GoogleCodeExporter commented 9 years ago
You're true. My bad for the copy/paste fail...

Original comment by sebast...@hyperweek.com on 28 Jun 2011 at 9:33

GoogleCodeExporter commented 9 years ago
Running the management command without changing the LANGUAGES setting raises a 
TransactionManagementError here. I'm using MySQL.
{{{
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/path/to/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/path/to/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/path/to/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/path/to/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/path/to/cms/contrib/modeltranslation/management/commands/sync_translation_fields.py", line 87, in handle
    transaction.leave_transaction_management()
  File "/path/to/django/db/transaction.py", line 56, in leave_transaction_management
    connection.leave_transaction_management()
  File "/path/to/django/db/backends/__init__.py", line 115, in leave_transaction_management
    raise TransactionManagementError("Transaction managed block ended with "
django.db.transaction.TransactionManagementError: Transaction managed block 
ended with pending COMMIT/ROLLBACK
}}}

Original comment by desch...@newmediayuppies.com on 30 Jun 2011 at 9:54

GoogleCodeExporter commented 9 years ago
Yep, transaction management has changed in Django 1.3.
Here is the patch : 
https://github.com/hyperweek/django-modeltranslation/commit/552d74ee93a1a1372585
006518289abd023c006b.
Cheers,

Original comment by sebastie...@gmail.com on 30 Jun 2011 at 9:57

GoogleCodeExporter commented 9 years ago

Original comment by eschler on 10 Jul 2012 at 9:13

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r149.

Original comment by eschler on 11 Jul 2012 at 12:57

GoogleCodeExporter commented 9 years ago

Original comment by eschler on 11 Jul 2012 at 12:58

GoogleCodeExporter commented 9 years ago
The management command is in trunk now. Thanks for your help!

Please note, that i had to pass the connection to db_type in get_sync_sql to 
make it work with Django 1.4. Yet have to check if this breaks anything in 
older versions...

Original comment by eschler on 11 Jul 2012 at 1:01