#11900: commit_on_success: Handle Exception in commit()
---------------------------------------------------+------------------------
Reporter: guettli | Owner:
gabrielhurley
Status: assigned | Milestone: 1.2
Component: Database layer (models, ORM) | Version: 1.0
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Comment (by guettli):
Hi Gabriel,
thank you for your question. This script results in
{{{
Traceback (most recent call last):
File "djangotest_tbz/script.py", line 10, in <module>
main()
File "/home/djangotest_tbz_d/django/db/transaction.py", line 310, in
_commit_on_success
leave_transaction_management(using=db)
File "/home/djangotest_tbz_d/django/db/transaction.py", line 87, in
leave_transaction_management
raise TransactionManagementError("Transaction managed block ended with
pending COMMIT/ROLLBACK")
django.db.transaction.TransactionManagementError: Transaction managed
block ended with pending COMMIT/ROLLBACK
}}}
I just tried it with latest trunk ([12761]). Postgres (psycopg2) evaluates
Foreign-Key
Constraints lazy (deferrable). If you break this constraint, you get an
exception
during commit. But you don't see the real problem.
{{{
from django.db import transaction, connection
@transaction.commit_on_success
def main():
cursor=connection.cursor()
cursor.execute('INSERT INTO auth_user_groups VALUES (DEFAULT,
10000000, 1000000);')
transaction.set_dirty()
if __name__=='__main__':
main()
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/11900#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.