Changeset 7145
- Timestamp:
- 02/22/08 06:50:10 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r7134 r7145 72 72 Andrew Brehaut <http://brehaut.net/blog> 73 73 brut.alll@gmail.com 74 btoll@bestweb.net 74 75 Jonathan Buchanan <jonathan.buchanan@gmail.com> 75 76 Can Burak Çilingir <canburak@cs.bilgi.edu.tr> django/trunk/django/core/management/commands/loaddata.py
r7037 r7145 31 31 32 32 # Keep a count of the installed objects and fixtures 33 count = [0, 0] 33 fixture_count = 0 34 object_count = 0 34 35 models = set() 35 36 … … 66 67 print "Skipping fixture '%s': %s is not a known serialization format" % (fixture_name, format) 67 68 68 for fixture_dir in app_fixtures + list(settings.FIXTURE_DIRS) + ['']: 69 if os.path.isabs(fixture_name): 70 fixture_dirs = [fixture_name] 71 else: 72 fixture_dirs = app_fixtures + list(settings.FIXTURE_DIRS) + [''] 73 74 for fixture_dir in fixture_dirs: 69 75 if verbosity > 1: 70 76 print "Checking %s for fixtures..." % humanize(fixture_dir) … … 87 93 return 88 94 else: 89 count[1]+= 195 fixture_count += 1 90 96 if verbosity > 0: 91 97 print "Installing %s fixture '%s' from %s." % \ … … 94 100 objects = serializers.deserialize(format, fixture) 95 101 for obj in objects: 96 count[0]+= 1102 object_count += 1 97 103 models.add(obj.object.__class__) 98 104 obj.save() … … 114 120 (format, fixture_name, humanize(fixture_dir)) 115 121 116 if count[0]> 0:122 if object_count > 0: 117 123 sequence_sql = connection.ops.sequence_reset_sql(self.style, models) 118 124 if sequence_sql: … … 125 131 transaction.leave_transaction_management() 126 132 127 if count[0]== 0:133 if object_count == 0: 128 134 if verbosity >= 2: 129 135 print "No fixtures found." 130 136 else: 131 137 if verbosity > 0: 132 print "Installed %d object(s) from %d fixture(s)" % tuple(count)138 print "Installed %d object(s) from %d fixture(s)" % (object_count, fixture_count) django/trunk/tests/regressiontests/fixtures_regress/models.py
r6249 r7145 2 2 from django.contrib.auth.models import User 3 3 from django.conf import settings 4 import os 4 5 5 6 class Animal(models.Model): … … 29 30 return unicode(name) + u' is owned by ' + unicode(self.owner) 30 31 32 class Absolute(models.Model): 33 name = models.CharField(max_length=40) 34 35 load_count = 0 36 37 def __init__(self, *args, **kwargs): 38 super(Absolute, self).__init__(*args, **kwargs) 39 Absolute.load_count += 1 40 41 31 42 __test__ = {'API_TESTS':""" 32 43 >>> from django.core import management … … 50 61 [<Stuff: None is owned by None>] 51 62 63 ############################################### 64 # Regression test for ticket #6436 -- 65 # os.path.join will throw away the initial parts of a path if it encounters 66 # an absolute path. This means that if a fixture is specified as an absolute path, 67 # we need to make sure we don't discover the absolute path in every fixture directory. 68 69 >>> load_absolute_path = os.path.join(os.path.dirname(__file__), 'fixtures', 'absolute.json') 70 >>> management.call_command('loaddata', load_absolute_path, verbosity=0) 71 >>> Absolute.load_count 72 1 73 52 74 """}
