Ticket #18017: loaddata_refactored.diff
File loaddata_refactored.diff, 2.8 KB (added by , 13 years ago) |
---|
-
django/core/management/commands/loaddata.py
33 33 default=DEFAULT_DB_ALIAS, help='Nominates a specific database to load ' 34 34 'fixtures into. Defaults to the "default" database.'), 35 35 ) 36 37 def _rollback_transaction(self, using): 38 transaction.rollback(using=using) 39 transaction.leave_transaction_management(using=using) 36 40 37 41 def handle(self, *fixture_labels, **options): 38 42 using = options.get('database') … … 134 138 self.style.ERROR("Problem installing fixture '%s': %s is not a known serialization format.\n" % 135 139 (fixture_name, format))) 136 140 if commit: 137 transaction.rollback(using=using) 138 transaction.leave_transaction_management(using=using) 141 self._rollback_transaction(using) 139 142 return 140 143 141 144 if os.path.isabs(fixture_name): … … 174 177 self.stderr.write(self.style.ERROR("Multiple fixtures named '%s' in %s. Aborting.\n" % 175 178 (fixture_name, humanize(fixture_dir)))) 176 179 if commit: 177 transaction.rollback(using=using) 178 transaction.leave_transaction_management(using=using) 180 self._rollback_transaction(using) 179 181 return 180 182 181 183 fixture_count += 1 … … 216 218 self.style.ERROR("No fixture data found for '%s'. (File format may be invalid.)\n" % 217 219 (fixture_name))) 218 220 if commit: 219 transaction.rollback(using=using) 220 transaction.leave_transaction_management(using=using) 221 self._rollback_transaction(using) 221 222 return 222 223 223 224 # Since we disabled constraint checks, we must manually check for … … 229 230 raise 230 231 except Exception: 231 232 if commit: 232 transaction.rollback(using=using) 233 transaction.leave_transaction_management(using=using) 233 self._rollback_transaction(using) 234 234 if show_traceback: 235 235 traceback.print_exc() 236 236 else: