HI All!

When I use my own command with manage.py and got any psycopg2
exception on commit, not other exception, I can't create any object in
model after rollback even if I do
transaction.enter_transaction_management() and
transaction.managed(True)

How can I save and commit data after psycopg2.OperationalError
exception?

cursor = connection.cursor()
transaction.enter_transaction_management()
transaction.managed(True)

try:
  # import log initialization
  import_log = ImportLog.objects.create(registry=registry,
md5sum=md5sum(src), size=os.   stat(src).st_size,
commit_date_begin=datetime.datetime.now())
  transaction.commit()

  # save all objects
  for obj in objects:
    obj.save()

  # write data to import log
  import_log.commit_date_end = datetime.datetime.now()
  import_log.save()

  transaction.commit()
except:
  transaction.rollback()
  transaction.leave_transaction_management()

  # HOW TO CREATE SOME OBJECT HERE???
  # THIS CODE DOES NOT WORK if psycopg2.OperationalError exception
raised, WHY?
  cursor = connection.cursor()
  transaction.enter_transaction_management()
  transaction.managed(True)
  import_log = ImportLog.objects.get(registry=registry,
md5sum=source_md5sum)
  import_log.rollback_date = datetime.datetime.now()
  import_log.rollback_savepoint = object_count
  import_log.save()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to