Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  4. *
  5. * Mumble-Django is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This package is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. """
  15. from django.db import connection, transaction
  16. from django.db.models import signals
  17. from mumble import models
  18. from update_schema import update_schema
  19. from server_detect import find_existing_instances
  20. if not transaction.is_managed():
  21. managed_before = False
  22. transaction.enter_transaction_management(True)
  23. transaction.managed(True)
  24. else:
  25. managed_before = True
  26. cursor = connection.cursor()
  27. try:
  28. cursor.execute( "SELECT server_id FROM mumble_mumble;" )
  29. except cursor.db.connection.Error:
  30. # server_id field does not exist -> DB needs to be updated.
  31. transaction.rollback()
  32. signals.post_syncdb.connect( update_schema, sender=models );
  33. else:
  34. transaction.rollback()
  35. signals.post_syncdb.connect( find_existing_instances, sender=models );
  36. finally:
  37. if not managed_before:
  38. transaction.managed(False)
  39. transaction.leave_transaction_management()