Ticket #4371: russels_070913_suggestions.diff
File russels_070913_suggestions.diff, 3.1 KB (added by , 17 years ago) |
---|
-
loaddata.py
58 58 else: 59 59 formats = [] 60 60 61 if verbosity > 0:62 if formats:61 if formats: 62 if verbosity > 0: 63 63 print "Loading '%s' fixtures..." % fixture_name 64 else: 65 print "Skipping fixture '%s': %s is not a known serialization format" % (fixture_name, format) 64 else: 65 sys.stderr.write( 66 self.style.ERROR("Problem installing fixture '%s': %s is not a known serialization format." % 67 (fixture_name, format))) 68 transaction.rollback() 69 transaction.leave_transaction_management() 70 return 66 71 67 72 for fixture_dir in app_fixtures + list(settings.FIXTURE_DIRS) + ['']: 68 73 if verbosity > 1: 69 74 print "Checking %s for fixtures..." % humanize(fixture_dir) 70 75 71 76 label_found = False 77 local_count = [0, 0] 72 78 for format in formats: 73 79 serializer = serializers.get_serializer(format) 74 80 if verbosity > 1: … … 85 91 transaction.leave_transaction_management() 86 92 return 87 93 else: 88 count[1] += 194 local_count[1] += 1 89 95 if verbosity > 0: 90 96 print "Installing %s fixture '%s' from %s." % \ 91 97 (format, fixture_name, humanize(fixture_dir)) 92 98 try: 93 99 objects = serializers.deserialize(format, fixture) 94 100 for obj in objects: 95 count[0] += 1101 local_count[0] += 1 96 102 models.add(obj.object.__class__) 97 103 obj.save() 98 104 label_found = True … … 109 115 if verbosity > 1: 110 116 print "No %s fixture '%s' in %s." % \ 111 117 (format, fixture_name, humanize(fixture_dir)) 118 119 count[0] += local_count[0] 120 count[1] += local_count[1] 121 # If we found a fixture file to load, but no objects loaded, assume 122 if local_count[1] > 0 and local_count[0] == 0: 123 sys.stderr.write( 124 self.style.ERROR("Empty fixture file '%s' found. (File format may be invalid.)" % 125 (fixture_name))) 126 transaction.rollback() 127 transaction.leave_transaction_management() 128 return 112 129 113 130 if count[0] > 0: 114 131 sequence_sql = connection.ops.sequence_reset_sql(self.style, models)