Ticket #490: management.patch

File management.patch, 1.9 KB (added by eugene@…, 19 years ago)

patch

  • management.py

     
    218218
    219219    # Check that the package exists in the database.
    220220    cursor.execute("SELECT 1 FROM packages WHERE label = %s", [app_label])
    221     if cursor.rowcount < 1:
     221    if cursor.rowcount < 0:
     222        # can be -1 (==undetermined) according to http://www.python.org/peps/pep-0249.html
     223        flag = cursor.fetchone() is None
     224    else:
     225        flag = cursor.rowcount < 1
     226    if flag:
    222227#         sys.stderr.write("The '%s' package isn't installed.\n" % app_label)
    223228        print _get_packages_insert(app_label)
    224229
     
    232237        contenttypes_seen[opts.module_name] = 1
    233238        for codename, name in perms:
    234239            cursor.execute("SELECT 1 FROM auth_permissions WHERE package = %s AND codename = %s", (app_label, codename))
    235             if cursor.rowcount < 1:
     240            if cursor.rowcount < 0:
     241                # can be -1 (==undetermined) according to http://www.python.org/peps/pep-0249.html
     242                flag = cursor.fetchone() is None
     243            else:
     244                flag = cursor.rowcount < 1
     245            if flag:
    236246#                 sys.stderr.write("The '%s.%s' permission doesn't exist.\n" % (app_label, codename))
    237247                print _get_permission_insert(name, codename, opts)
    238248        cursor.execute("SELECT 1 FROM content_types WHERE package = %s AND python_module_name = %s", (app_label, opts.module_name))
    239         if cursor.rowcount < 1:
     249        if cursor.rowcount < 0:
     250            # can be -1 (==undetermined) according to http://www.python.org/peps/pep-0249.html
     251            flag = cursor.fetchone() is None
     252        else:
     253            flag = cursor.rowcount < 1
     254        if flag:
    240255#             sys.stderr.write("The '%s.%s' content type doesn't exist.\n" % (app_label, opts.module_name))
    241256            print _get_contenttype_insert(opts)
    242257
Back to Top