Django

Code

Changeset 3665

Show
Ignore:
Timestamp:
08/27/06 11:36:27 (2 years ago)
Author:
jpellerin
Message:

[multi-db] Merge trunk to [3660].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/multiple-db-support/django/conf/global_settings.py

    r3581 r3665  
    300300 
    301301AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',) 
     302 
     303########### 
     304# TESTING # 
     305########### 
     306 
     307TEST_RUNNER='django.test.simple.run_tests' 
  • django/branches/multiple-db-support/django/contrib/auth/management.py

    r3172 r3665  
    1717    return perms + list(opts.permissions) 
    1818 
    19 def create_permissions(app, created_models): 
     19def create_permissions(app, created_models, verbosity): 
    2020    from django.contrib.contenttypes.models import ContentType 
    2121    from django.contrib.auth.models import Permission 
     
    2828            p, created = Permission.objects.get_or_create(codename=codename, content_type__pk=ctype.id, 
    2929                defaults={'name': name, 'content_type': ctype}) 
    30             if created
     30            if created and verbosity >= 2
    3131                print "Adding permission '%s'" % p 
    3232 
    33 def create_superuser(app, created_models): 
     33def create_superuser(app, created_models, verbosity, **kwargs): 
    3434    from django.contrib.auth.models import User 
    3535    from django.contrib.auth.create_superuser import createsuperuser as do_create 
    36     if User in created_models
     36    if User in created_models and kwargs.get('interactive', True)
    3737        msg = "\nYou just installed Django's auth system, which means you don't have " \ 
    3838                "any superusers defined.\nWould you like to create one now? (yes/no): " 
  • django/branches/multiple-db-support/django/contrib/contenttypes/management.py

    r3148 r3665  
    66from django.db.models import get_models, signals 
    77 
    8 def create_contenttypes(app, created_models): 
     8def create_contenttypes(app, created_models, verbosity): 
    99    from django.contrib.contenttypes.models import ContentType 
    1010    app_models = get_models(app) 
     
    2020                app_label=opts.app_label, model=opts.object_name.lower()) 
    2121            ct.save() 
    22             print "Adding content type '%s | %s'" % (ct.app_label, ct.model) 
     22            if verbosity >= 2: 
     23                print "Adding content type '%s | %s'" % (ct.app_label, ct.model) 
    2324 
    2425dispatcher.connect(create_contenttypes, signal=signals.post_syncdb) 
  • django/branches/multiple-db-support/django/contrib/sites/management.py

    r2809 r3665  
    88from django.contrib.sites import models as site_app 
    99 
    10 def create_default_site(app, created_models): 
     10def create_default_site(app, created_models, verbosity): 
    1111    if Site in created_models: 
    12         print "Creating example.com Site object" 
     12        if verbosity >= 2: 
     13            print "Creating example.com Site object" 
    1314        s = Site(domain="example.com", name="example.com") 
    1415        s.save() 
  • django/branches/multiple-db-support/django/core/management.py

    r3581 r3665  
    279279    return map(str, final_output) 
    280280 
    281 def syncdb(): 
     281def syncdb(verbosity=2, interactive=True): 
    282282    "Creates the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." 
    283283    from django.db import connection, transaction, models, get_creation_module 
     
    327327                    pending_references[refto] = refs 
    328328            sql.extend(_get_sql_for_pending_references(model, pending_references)) 
    329             print "Creating table %s" % model._meta.db_table 
     329            if verbosity >= 2: 
     330                print "Creating table %s" % model._meta.db_table 
    330331            for statement in sql: 
    331332                cursor.execute(statement) 
     
    336337                sql = _get_many_to_many_sql_for_model(model) 
    337338                if sql: 
    338                     print "Creating many-to-many tables for %s model" % model.__name__ 
     339                    if verbosity >= 2: 
     340                        print "Creating many-to-many tables for %s model" % model.__name__ 
    339341                    for statement in sql: 
    340342                        cursor.execute(statement) 
     
    346348    for app in models.get_apps(): 
    347349        dispatcher.send(signal=signals.post_syncdb, sender=app, 
    348             app=app, created_models=created_models) 
     350            app=app, created_models=created_models,  
     351            verbosity=verbosity, interactive=interactive) 
    349352 
    350353        # Install initial data for the app (but only if this is a model we've 
     
    10331036runfcgi.args = '[various KEY=val options, use `runfcgi help` for help]' 
    10341037 
     1038def test(verbosity, app_labels): 
     1039    "Runs the test suite for the specified applications" 
     1040    from django.conf import settings 
     1041    from django.db.models import get_app, get_apps 
     1042 
     1043    if len(app_labels) == 0: 
     1044        app_list = get_apps() 
     1045    else: 
     1046        app_list = [get_app(app_label) for app_label in app_labels] 
     1047     
     1048    test_path = settings.TEST_RUNNER.split('.') 
     1049    # Allow for Python 2.5 relative paths 
     1050    if len(test_path) > 1: 
     1051        test_module_name = '.'.join(test_path[:-1]) 
     1052    else: 
     1053        test_module_name = '.' 
     1054    test_module = __import__(test_module_name, [],[],test_path[-1]) 
     1055    test_runner = getattr(test_module, test_path[-1]) 
     1056     
     1057    test_runner(app_list, verbosity) 
     1058test.help_doc = 'Runs the test suite for the specified applications, or the entire site if no apps are specified' 
     1059test.args = '[--verbosity] ' + APP_ARGS 
     1060 
    10351061# Utilities for command-line script 
    10361062 
     
    10571083    'syncdb': syncdb, 
    10581084    'validate': validate, 
     1085    'test':test, 
    10591086} 
    10601087 
     
    11071134    parser.add_option('--plain', action='store_true', dest='plain', 
    11081135        help='Tells Django to use plain Python, not IPython, for "shell" command.') 
     1136    parser.add_option('--noinput', action='store_false', dest='interactive', default=True, 
     1137        help='Tells Django to NOT prompt the user for input of any kind.') 
    11091138    parser.add_option('--noreload', action='store_false', dest='use_reloader', default=True, 
    11101139        help='Tells Django to NOT use the auto-reloader when running the development server.') 
     1140    parser.add_option('--verbosity', action='store', dest='verbosity', default='2', 
     1141        type='choice', choices=['0', '1', '2'], 
     1142        help='Verbosity level; 0=minimal output, 1=normal output, 2=all output') 
     1143 
    11111144    options, args = parser.parse_args(argv[1:]) 
    11121145 
     
    11351168    if action == 'shell': 
    11361169        action_mapping[action](options.plain is True) 
    1137     elif action in ('syncdb', 'validate', 'diffsettings', 'dbshell'): 
     1170    elif action in ('validate', 'diffsettings', 'dbshell'): 
    11381171        action_mapping[action]() 
     1172    elif action == 'syncdb': 
     1173        action_mapping[action](int(options.verbosity), options.interactive) 
    11391174    elif action == 'inspectdb': 
    11401175        try: 
     
    11471182        try: 
    11481183            action_mapping[action](args[1]) 
     1184        except IndexError: 
     1185            parser.print_usage_and_exit() 
     1186    elif action == 'test': 
     1187        try: 
     1188            action_mapping[action](int(options.verbosity), args[1:]) 
    11491189        except IndexError: 
    11501190            parser.print_usage_and_exit()