Django

Code

Changeset 7704

Show
Ignore:
Timestamp:
06/19/08 08:24:39 (3 months ago)
Author:
russellm
Message:

Fixed #6719 -- Added a --traceback option to syncdb to provide a stack trace when custom SQL loading fails. Also added documentation for the --traceback option. Thanks to guettli for the patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management/commands/syncdb.py

    r7623 r7704  
    2626        verbosity = int(options.get('verbosity', 1)) 
    2727        interactive = options.get('interactive') 
     28        show_traceback = options.get('traceback', False) 
    2829 
    2930        self.style = no_style() 
     
    120121                                cursor.execute(sql) 
    121122                        except Exception, e: 
    122                             sys.stderr.write("Failed to install custom SQL for %s.%s model: %s" % \ 
     123                            sys.stderr.write("Failed to install custom SQL for %s.%s model: %s\n" % \ 
    123124                                                (app_name, model._meta.object_name, e)) 
     125                            if show_traceback: 
     126                                import traceback 
     127                                traceback.print_exc() 
    124128                            transaction.rollback_unless_managed() 
    125129                        else: 
    126130                            transaction.commit_unless_managed() 
    127  
     131                    else: 
     132                        if verbosity >= 2: 
     133                            print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name) 
    128134        # Install SQL indicies for all newly created models 
    129135        for app in models.get_apps(): 
  • django/trunk/docs/django-admin.txt

    r7648 r7704  
    756756Note that this option is unnecessary in ``manage.py``, because it uses 
    757757``settings.py`` from the current project by default. 
     758 
     759--traceback 
     760----------- 
     761 
     762Example usage:: 
     763 
     764    django-admin.py syncdb --traceback 
     765 
     766By default, ``django-admin.py`` will show a simple error message whenever an 
     767error occurs. If you specify ``--traceback``, ``django-admin.py``  will 
     768output a full stack trace whenever an exception is raised. 
    758769 
    759770Extra niceties