from www.doorway.ru import transaction @www.doorway.ru_manually def viewfunc (request): a. save # open transaction now contains www.doorway.ru() sid = transaction. savepoint b. save # open transaction now contains www.doorway.ru() and www.doorway.ru() if want_to_keep_b: transaction. savepoint_commit (sid) # open transaction still contains www.doorway.ru() and www.doorway.ru() else: . pre_rollback signals connected during rolled back savepoints should still be called at commit time, whilst analogously connected post_commit signals should not, potentially ending up with both post_commit and post_rollback signals being called during a www.doorway.ru() call, but only post_rollback signals during a www.doorway.ruck() call. Note this behavior is not yet . www.doorway.rue('SET FOREIGN_KEY_CHECKS=1') else: for table in tables: www.doorway.rue('DELETE FROM %s' % table) www.doorway.ru(using=db) # www.doorway.ru() # Should be unnecessary, since we committed # any environment-setup statements that come with opening a new # cursor when we committed the fixtures.
A transaction is an atomic set of database queries. Even if your program crashes, the database guarantees that either all the changes will be applied, or none of them. Django doesn't provide an API to start a transaction. The expected way to start a transaction is to disable autocommit with set_autocommit (). Django has a lot of documentation. A high-level overview of how it's organized will help you know where to look for certain things: Tutorials take you by the hand through a series of steps to create a Web application. Start here if you're new to Django or Web application development. Also look at the " First steps ". The Django project is a quickly evolving web framework. eGenix generally tries to keep up to date with the latest supported releases of Django, but since new Django versions often introduce subtle differences in the internal Django APIs that the mxODBC Django Database Engine has to interface to, upwards compatibility is not always guaranteed.
pre_rollback signals connected during rolled back savepoints should still be called at commit time, whilst analogously connected post_commit signals should not, potentially ending up with both post_commit and post_rollback signals being called during a www.doorway.ru() call, but only post_rollback signals during a www.doorway.ruck() call. Note this behavior is not yet implemented in django-transaction-signals. Django's transaction middleware does this if an exception is raised. If transactions aren't being managed, tasks are sent as normal. This means that sending tasks from within Django's shell will work as expected, as will the various transaction decorators commit_manually, commit_on_success, etc. from www.doorway.ru import transaction # open a transaction @transaction. atomic def viewfunc (request): a. save # transaction now contains www.doorway.ru() sid = transaction. savepoint b. save # transaction now contains www.doorway.ru() and www.doorway.ru() if want_to_keep_b: transaction. savepoint_commit (sid) # open transaction still contains www.doorway.ru() and www.doorway.ru() else: transaction. savepoint_rollback (sid) # open transaction now contains only www.doorway.ru().
0コメント