Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #4431 -- Added a --traceback option for dumpdata and loaddata (…

…which

shows how it can be used for other commands as well). Thanks, dakrauth.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6936 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fbf49dfceed2958da3d6edcbe6119284bf95894e 1 parent 9229c34
Malcolm Tredinnick authored December 17, 2007
2  django/core/management/base.py
@@ -27,6 +27,8 @@ class BaseCommand(object):
27 27
             help='The Python path to a settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.'),
28 28
         make_option('--pythonpath',
29 29
             help='A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".'),
  30
+        make_option('--traceback', action='store_true',
  31
+            help='Print traceback on exception'),
30 32
     )
31 33
     help = ''
32 34
     args = ''
3  django/core/management/commands/dumpdata.py
@@ -19,6 +19,7 @@ def handle(self, *app_labels, **options):
19 19
 
20 20
         format = options.get('format', 'json')
21 21
         indent = options.get('indent', None)
  22
+        show_traceback = options.get('traceback', False)
22 23
 
23 24
         if len(app_labels) == 0:
24 25
             app_list = get_apps()
@@ -42,4 +43,6 @@ def handle(self, *app_labels, **options):
42 43
         try:
43 44
             return serializers.serialize(format, objects, indent=indent)
44 45
         except Exception, e:
  46
+            if show_traceback:
  47
+                raise
45 48
             raise CommandError("Unable to serialize database: %s" % e)
7  django/core/management/commands/loaddata.py
@@ -27,6 +27,7 @@ def handle(self, *fixture_labels, **options):
27 27
         self.style = no_style()
28 28
 
29 29
         verbosity = int(options.get('verbosity', 1))
  30
+        show_traceback = options.get('traceback', False)
30 31
 
31 32
         # Keep a count of the installed objects and fixtures
32 33
         count = [0, 0]
@@ -98,11 +99,13 @@ def handle(self, *fixture_labels, **options):
98 99
                                 label_found = True
99 100
                             except Exception, e:
100 101
                                 fixture.close()
  102
+                                transaction.rollback()
  103
+                                transaction.leave_transaction_management()
  104
+                                if show_traceback:
  105
+                                    raise
101 106
                                 sys.stderr.write(
102 107
                                     self.style.ERROR("Problem installing fixture '%s': %s\n" %
103 108
                                          (full_path, str(e))))
104  
-                                transaction.rollback()
105  
-                                transaction.leave_transaction_management()
106 109
                                 return
107 110
                             fixture.close()
108 111
                     except:

0 notes on commit fbf49df

Please sign in to comment.
Something went wrong with that request. Please try again.