diff -ur db/models/base.py /sw/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/base.py
old
|
new
|
|
195 | 195 | backend.get_pk_default_value())) |
196 | 196 | if self._meta.has_auto_field and not pk_set: |
197 | 197 | setattr(self, self._meta.pk.attname, backend.get_last_insert_id(cursor, self._meta.db_table, self._meta.pk.column)) |
198 | | transaction.commit_unless_managed() |
| 198 | transaction.commit_unless_managed(connection=self._meta.connection) |
199 | 199 | |
200 | 200 | # Run any post-save hooks. |
201 | 201 | dispatcher.send(signal=signals.post_save, sender=self.__class__, instance=self) |
… |
… |
|
377 | 377 | backend.quote_name(rel_field.m2m_column_name()), |
378 | 378 | backend.quote_name(rel_field.m2m_reverse_name())) |
379 | 379 | cursor.executemany(sql, [(this_id, i) for i in id_list]) |
380 | | transaction.commit_unless_managed() |
| 380 | transaction.commit_unless_managed(connection=self._meta.connection) |
381 | 381 | |
382 | 382 | ############################################ |
383 | 383 | # HELPER FUNCTIONS (CURRIED MODEL METHODS) # |
… |
… |
|
398 | 398 | backend.quote_name(ordered_obj.pk.column)) |
399 | 399 | rel_val = getattr(self, ordered_obj.order_with_respect_to.rel.field_name) |
400 | 400 | cursor.executemany(sql, [(i, rel_val, j) for i, j in enumerate(id_list)]) |
401 | | transaction.commit_unless_managed() |
| 401 | transaction.commit_unless_managed(connection=self._meta.connection) |
402 | 402 | |
403 | 403 | def method_get_order(ordered_obj, self): |
404 | 404 | connection_info = ordered_obj.connection_info |
diff -ur db/transaction.py /sw/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/transaction.py
old
|
new
|
|
111 | 111 | return state[thread_ident][-1] |
112 | 112 | return settings.TRANSACTIONS_MANAGED |
113 | 113 | |
114 | | def managed(flag=True): |
| 114 | def managed(connection=connection,flag=True): |
115 | 115 | """ |
116 | 116 | Puts the transaction manager into a manual state: managed transactions have |
117 | 117 | to be committed explicitely by the user. If you switch off transaction |
… |
… |
|
128 | 128 | else: |
129 | 129 | raise TransactionManagementError("This code isn't under transaction management") |
130 | 130 | |
131 | | def commit_unless_managed(): |
| 131 | def commit_unless_managed(connection=connection): |
132 | 132 | """ |
133 | 133 | Commits changes if the system is not in managed transaction mode. |
134 | 134 | """ |
… |
… |
|
137 | 137 | else: |
138 | 138 | set_dirty() |
139 | 139 | |
140 | | def rollback_unless_managed(): |
| 140 | def rollback_unless_managed(connection=connection): |
141 | 141 | """ |
142 | 142 | Rolls back changes if the system is not in managed transaction mode. |
143 | 143 | """ |
… |
… |
|
146 | 146 | else: |
147 | 147 | set_dirty() |
148 | 148 | |
149 | | def commit(): |
| 149 | def commit(connection=connection): |
150 | 150 | """ |
151 | 151 | Does the commit itself and resets the dirty flag. |
152 | 152 | """ |
153 | 153 | connection._commit() |
154 | 154 | set_clean() |
155 | 155 | |
156 | | def rollback(): |
| 156 | def rollback(connection=connection): |
157 | 157 | """ |
158 | 158 | This function does the rollback itself and resets the dirty flag. |
159 | 159 | """ |