Changeset 3712
- Timestamp:
- 09/03/06 21:20:26 (2 years ago)
- Files:
-
- django/branches/multiple-db-support/AUTHORS (modified) (2 diffs)
- django/branches/multiple-db-support/django/bin/compile-messages.py (modified) (1 diff)
- django/branches/multiple-db-support/django/conf/global_settings.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/views/doc.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/auth/models.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/sitemaps (copied) (copied from django/trunk/django/contrib/sitemaps)
- django/branches/multiple-db-support/django/contrib/sitemaps/__init__.py (copied) (copied from django/trunk/django/contrib/sitemaps/__init__.py)
- django/branches/multiple-db-support/django/contrib/sitemaps/templates (copied) (copied from django/trunk/django/contrib/sitemaps/templates)
- django/branches/multiple-db-support/django/contrib/sitemaps/templates/sitemap_index.xml (copied) (copied from django/trunk/django/contrib/sitemaps/templates/sitemap_index.xml)
- django/branches/multiple-db-support/django/contrib/sitemaps/templates/sitemap.xml (copied) (copied from django/trunk/django/contrib/sitemaps/templates/sitemap.xml)
- django/branches/multiple-db-support/django/contrib/sitemaps/views.py (copied) (copied from django/trunk/django/contrib/sitemaps/views.py)
- django/branches/multiple-db-support/django/core/management.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/core/serializers/base.py (modified) (16 diffs)
- django/branches/multiple-db-support/django/core/serializers/json.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/backends/postgresql_psycopg2/base.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/db/backends/util.py (modified) (1 diff)
- django/branches/multiple-db-support/django/template/defaulttags.py (modified) (1 diff)
- django/branches/multiple-db-support/django/template/__init__.py (modified) (5 diffs)
- django/branches/multiple-db-support/django/template/loader.py (modified) (1 diff)
- django/branches/multiple-db-support/django/template/loader_tags.py (modified) (1 diff)
- django/branches/multiple-db-support/django/test/simple.py (modified) (1 diff)
- django/branches/multiple-db-support/django/test/utils.py (modified) (5 diffs)
- django/branches/multiple-db-support/django/utils/datastructures.py (modified) (1 diff)
- django/branches/multiple-db-support/django/views/debug.py (modified) (3 diffs)
- django/branches/multiple-db-support/django/views/static.py (modified) (1 diff)
- django/branches/multiple-db-support/docs/add_ons.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/contributing.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/django-admin.txt (modified) (3 diffs)
- django/branches/multiple-db-support/docs/faq.txt (modified) (2 diffs)
- django/branches/multiple-db-support/docs/settings.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/sitemaps.txt (copied) (copied from django/trunk/docs/sitemaps.txt)
- django/branches/multiple-db-support/docs/sites.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/templates_python.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/testing.txt (copied) (copied from django/trunk/docs/testing.txt)
- django/branches/multiple-db-support/setup.cfg (copied) (copied from django/trunk/setup.cfg)
- django/branches/multiple-db-support/tests/doctest.py (deleted)
- django/branches/multiple-db-support/tests/modeltests/basic/models.py (modified) (5 diffs)
- django/branches/multiple-db-support/tests/modeltests/choices/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/custom_columns/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/custom_managers/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/custom_methods/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/custom_pk/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/empty/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/field_defaults/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/generic_relations/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/get_latest/models.py (modified) (3 diffs)
- django/branches/multiple-db-support/tests/modeltests/get_or_create/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/invalid_models/models.py (modified) (1 diff)
- django/branches/multiple-db-support/tests/modeltests/lookup/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/m2m_and_m2o/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/m2m_intermediary/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/m2m_multiple/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/m2m_recursive/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/m2o_recursive2/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/m2o_recursive/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/manipulators/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/many_to_many/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/many_to_one/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/many_to_one_null/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/model_inheritance/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/multiple_databases/models.py (modified) (6 diffs)
- django/branches/multiple-db-support/tests/modeltests/mutually_referential/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/one_to_one/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/ordering/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/or_lookups/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/pagination/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/properties/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/reserved_names/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/reverse_lookup/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/save_delete_hooks/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/serializers/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/str/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/transactions/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/modeltests/validation/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/othertests (deleted)
- django/branches/multiple-db-support/tests/regressiontests/ansi_sql (added)
- django/branches/multiple-db-support/tests/regressiontests/ansi_sql/__init__.py (added)
- django/branches/multiple-db-support/tests/regressiontests/ansi_sql/models.py (added)
- django/branches/multiple-db-support/tests/regressiontests/ansi_sql/sql (added)
- django/branches/multiple-db-support/tests/regressiontests/ansi_sql/sql/car.sql (added)
- django/branches/multiple-db-support/tests/regressiontests/cache (copied) (copied from django/trunk/tests/regressiontests/cache)
- django/branches/multiple-db-support/tests/regressiontests/cache/__init__.py (copied) (copied from django/trunk/tests/regressiontests/cache/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/cache/models.py (copied) (copied from django/trunk/tests/regressiontests/cache/models.py)
- django/branches/multiple-db-support/tests/regressiontests/cache/tests.py (copied) (copied from django/trunk/tests/regressiontests/cache/tests.py)
- django/branches/multiple-db-support/tests/regressiontests/dateformat (copied) (copied from django/trunk/tests/regressiontests/dateformat)
- django/branches/multiple-db-support/tests/regressiontests/dateformat/__init__.py (copied) (copied from django/trunk/tests/regressiontests/dateformat/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/dateformat/models.py (copied) (copied from django/trunk/tests/regressiontests/dateformat/models.py)
- django/branches/multiple-db-support/tests/regressiontests/dateformat/tests.py (copied) (copied from django/trunk/tests/regressiontests/dateformat/tests.py)
- django/branches/multiple-db-support/tests/regressiontests/db_typecasts (copied) (copied from django/trunk/tests/regressiontests/db_typecasts)
- django/branches/multiple-db-support/tests/regressiontests/db_typecasts/__init__.py (copied) (copied from django/trunk/tests/regressiontests/db_typecasts/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/db_typecasts/models.py (copied) (copied from django/trunk/tests/regressiontests/db_typecasts/models.py)
- django/branches/multiple-db-support/tests/regressiontests/db_typecasts/tests.py (copied) (copied from django/trunk/tests/regressiontests/db_typecasts/tests.py)
- django/branches/multiple-db-support/tests/regressiontests/defaultfilters (copied) (copied from django/trunk/tests/regressiontests/defaultfilters)
- django/branches/multiple-db-support/tests/regressiontests/defaultfilters/__init__.py (copied) (copied from django/trunk/tests/regressiontests/defaultfilters/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/defaultfilters/models.py (copied) (copied from django/trunk/tests/regressiontests/defaultfilters/models.py)
- django/branches/multiple-db-support/tests/regressiontests/defaultfilters/tests.py (copied) (copied from django/trunk/tests/regressiontests/defaultfilters/tests.py)
- django/branches/multiple-db-support/tests/regressiontests/httpwrappers (copied) (copied from django/trunk/tests/regressiontests/httpwrappers)
- django/branches/multiple-db-support/tests/regressiontests/httpwrappers/__init__.py (copied) (copied from django/trunk/tests/regressiontests/httpwrappers/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/httpwrappers/models.py (copied) (copied from django/trunk/tests/regressiontests/httpwrappers/models.py)
- django/branches/multiple-db-support/tests/regressiontests/httpwrappers/tests.py (copied) (copied from django/trunk/tests/regressiontests/httpwrappers/tests.py)
- django/branches/multiple-db-support/tests/regressiontests/initial_sql_regress/models.py (modified) (1 diff)
- django/branches/multiple-db-support/tests/regressiontests/manager_db (added)
- django/branches/multiple-db-support/tests/regressiontests/manager_db/__init__.py (added)
- django/branches/multiple-db-support/tests/regressiontests/manager_db/models.py (added)
- django/branches/multiple-db-support/tests/regressiontests/manager_db/tests.py (added)
- django/branches/multiple-db-support/tests/regressiontests/manager_schema_manipulation (added)
- django/branches/multiple-db-support/tests/regressiontests/manager_schema_manipulation/__init__.py (added)
- django/branches/multiple-db-support/tests/regressiontests/manager_schema_manipulation/models.py (added)
- django/branches/multiple-db-support/tests/regressiontests/manager_schema_manipulation/tests.py (added)
- django/branches/multiple-db-support/tests/regressiontests/many_to_one_regress/models.py (modified) (1 diff)
- django/branches/multiple-db-support/tests/regressiontests/markup (copied) (copied from django/trunk/tests/regressiontests/markup)
- django/branches/multiple-db-support/tests/regressiontests/markup/__init__.py (copied) (copied from django/trunk/tests/regressiontests/markup/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/markup/models.py (copied) (copied from django/trunk/tests/regressiontests/markup/models.py)
- django/branches/multiple-db-support/tests/regressiontests/markup/tests.py (copied) (copied from django/trunk/tests/regressiontests/markup/tests.py)
- django/branches/multiple-db-support/tests/regressiontests/one_to_one_regress/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/regressiontests/request_isolation (added)
- django/branches/multiple-db-support/tests/regressiontests/request_isolation/__init__.py (added)
- django/branches/multiple-db-support/tests/regressiontests/request_isolation/models.py (added)
- django/branches/multiple-db-support/tests/regressiontests/request_isolation/tests.py (added)
- django/branches/multiple-db-support/tests/regressiontests/string_lookup/models.py (modified) (2 diffs)
- django/branches/multiple-db-support/tests/regressiontests/templates (copied) (copied from django/trunk/tests/regressiontests/templates)
- django/branches/multiple-db-support/tests/regressiontests/templates/__init__.py (copied) (copied from django/trunk/tests/regressiontests/templates/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/templates/models.py (copied) (copied from django/trunk/tests/regressiontests/templates/models.py)
- django/branches/multiple-db-support/tests/regressiontests/templates/tests.py (copied) (copied from django/trunk/tests/regressiontests/templates/tests.py)
- django/branches/multiple-db-support/tests/regressiontests/thread_isolation (added)
- django/branches/multiple-db-support/tests/regressiontests/thread_isolation/__init__.py (added)
- django/branches/multiple-db-support/tests/regressiontests/thread_isolation/models.py (added)
- django/branches/multiple-db-support/tests/regressiontests/thread_isolation/tests.py (added)
- django/branches/multiple-db-support/tests/regressiontests/urlpatterns_reverse (copied) (copied from django/trunk/tests/regressiontests/urlpatterns_reverse)
- django/branches/multiple-db-support/tests/regressiontests/urlpatterns_reverse/__init__.py (copied) (copied from django/trunk/tests/regressiontests/urlpatterns_reverse/__init__.py)
- django/branches/multiple-db-support/tests/regressiontests/urlpatterns_reverse/models.py (copied) (copied from django/trunk/tests/regressiontests/urlpatterns_reverse/models.py)
- django/branches/multiple-db-support/tests/regressiontests/urlpatterns_reverse/tests.py (copied) (copied from django/trunk/tests/regressiontests/urlpatterns_reverse/tests.py)
- django/branches/multiple-db-support/tests/runtests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/multiple-db-support/AUTHORS
r3621 r3712 127 127 Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/> 128 128 David Schein 129 Pete Shinners <pete@shinners.org> 129 130 sopel 130 131 Thomas Steinacher <tom@eggdrop.ch> … … 139 140 Geert Vanderkelen 140 141 Milton Waddams 142 Dan Watson <http://theidioteque.net/> 141 143 Rachel Willmer <http://www.willmer.com/kb/> 142 144 wojtek django/branches/multiple-db-support/django/bin/compile-messages.py
r3621 r3712 27 27 os.environ['djangocompilemo'] = pf + '.mo' 28 28 os.environ['djangocompilepo'] = pf + '.po' 29 cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"' 29 if sys.platform == 'win32': # Different shell-variable syntax 30 cmd = 'msgfmt -o "%djangocompilemo%" "%djangocompilepo%"' 31 else: 32 cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"' 30 33 os.system(cmd) 31 34 django/branches/multiple-db-support/django/conf/global_settings.py
r3665 r3712 305 305 ########### 306 306 307 TEST_RUNNER='django.test.simple.run_tests' 307 # The name of the method to use to invoke the test suite 308 TEST_RUNNER = 'django.test.simple.run_tests' 309 310 # The name of the database to use for testing purposes. 311 # If None, a name of 'test_' + DATABASE_NAME will be assumed 312 TEST_DATABASE_NAME = None 313 314 # Tuple of other test databases to create. Names in this tuple 315 # are suffixes that will be appended to TEST_DATABASE_NAME 316 TEST_DATABASES = [] 317 318 # Models to assign to each test database. This must be a list of 319 # dicts, with each dict key being a name from TEST_DATABASES and value 320 # a list of models or app_labels that will use that database. 321 TEST_DATABASE_MODELS = [] django/branches/multiple-db-support/django/contrib/admin/views/doc.py
r3621 r3712 329 329 views = [] 330 330 for p in urlpatterns: 331 if hasattr(p, ' get_callback'):331 if hasattr(p, '_get_callback'): 332 332 try: 333 views.append((p. get_callback(), base + p.regex.pattern))333 views.append((p._get_callback(), base + p.regex.pattern)) 334 334 except ViewDoesNotExist: 335 335 continue 336 336 elif hasattr(p, '_get_url_patterns'): 337 views.extend(extract_views_from_urlpatterns(p.url_patterns, base + p.regex.pattern)) 337 try: 338 patterns = p.url_patterns 339 except ImportError: 340 continue 341 views.extend(extract_views_from_urlpatterns(patterns, base + p.regex.pattern)) 338 342 else: 339 343 raise TypeError, _("%s does not appear to be a urlpattern object") % p django/branches/multiple-db-support/django/contrib/auth/models.py
r3427 r3712 34 34 Permissions are set globally per type of object, not per specific object instance. It is possible to say "Mary may change news stories," but it's not currently possible to say "Mary may change news stories, but only the ones she created herself" or "Mary may only change news stories that have a certain status or publication date." 35 35 36 Three basic permissions -- add, c reate and delete -- are automatically created for each Django model.36 Three basic permissions -- add, change and delete -- are automatically created for each Django model. 37 37 """ 38 38 name = models.CharField(_('name'), maxlength=50) django/branches/multiple-db-support/django/core/management.py
r3668 r3712 295 295 pass 296 296 297 # Send the post_syncdb signal, so individual apps can do whatever they need 298 # to do at this point. 297 # Install each app 299 298 for app in models.get_apps(): 300 299 # Install each application (models already installed will be skipped) … … 304 303 print "Created table %s" % model._meta.db_table 305 304 created_models.extend(created) 305 transaction.commit_unless_managed() 306 307 # Send the post_syncdb signal, so individual apps can do whatever they need 308 # to do at this point. 309 for app in models.get_apps(): 306 310 dispatcher.send(signal=signals.post_syncdb, sender=app, 307 311 app=app, created_models=created_models, 308 312 verbosity=verbosity, interactive=interactive) 309 transaction.commit_unless_managed()310 313 311 314 # Install initial data for the app (but only if this is a model we've django/branches/multiple-db-support/django/core/serializers/base.py
r3258 r3712 12 12 """Something bad happened during serialization.""" 13 13 pass 14 14 15 15 class DeserializationError(Exception): 16 16 """Something bad happened during deserialization.""" … … 21 21 Abstract serializer base class. 22 22 """ 23 23 24 24 def serialize(self, queryset, **options): 25 25 """ … … 27 27 """ 28 28 self.options = options 29 29 30 30 self.stream = options.get("stream", StringIO()) 31 31 32 32 self.start_serialization() 33 33 for obj in queryset: … … 45 45 self.end_serialization() 46 46 return self.getvalue() 47 47 48 48 def get_string_value(self, obj, field): 49 49 """ … … 51 51 """ 52 52 if isinstance(field, models.DateTimeField): 53 value = getattr(obj, field.name).strftime("%Y-%m-%d %H:%M:%S") 53 value = getattr(obj, field.name) 54 if value is None: 55 value = '' 56 else: 57 value = value.strftime("%Y-%m-%d %H:%M:%S") 54 58 elif isinstance(field, models.FileField): 55 59 value = getattr(obj, "get_%s_url" % field.name, lambda: None)() … … 57 61 value = field.flatten_data(follow=None, obj=obj).get(field.name, "") 58 62 return str(value) 59 63 60 64 def start_serialization(self): 61 65 """ … … 63 67 """ 64 68 raise NotImplementedError 65 69 66 70 def end_serialization(self): 67 71 """ … … 69 73 """ 70 74 pass 71 75 72 76 def start_object(self, obj): 73 77 """ … … 75 79 """ 76 80 raise NotImplementedError 77 81 78 82 def end_object(self, obj): 79 83 """ … … 81 85 """ 82 86 pass 83 87 84 88 def handle_field(self, obj, field): 85 89 """ … … 87 91 """ 88 92 raise NotImplementedError 89 93 90 94 def handle_fk_field(self, obj, field): 91 95 """ … … 93 97 """ 94 98 raise NotImplementedError 95 99 96 100 def handle_m2m_field(self, obj, field): 97 101 """ … … 99 103 """ 100 104 raise NotImplementedError 101 105 102 106 def getvalue(self): 103 107 """ … … 110 114 Abstract base deserializer class. 111 115 """ 112 116 113 117 def __init__(self, stream_or_string, **options): 114 118 """ … … 124 128 # and friends might fail...) 125 129 models.get_apps() 126 130 127 131 def __iter__(self): 128 132 return self 129 133 130 134 def next(self): 131 135 """Iteration iterface -- return the next item in the stream""" 132 136 raise NotImplementedError 133 137 134 138 class DeserializedObject(object): 135 139 """ 136 140 A deserialzed model. 137 141 138 142 Basically a container for holding the pre-saved deserialized data along 139 143 with the many-to-many data saved with the object. 140 144 141 145 Call ``save()`` to save the object (with the many-to-many data) to the 142 146 database; call ``save(save_m2m=False)`` to save just the object fields 143 147 (and not touch the many-to-many stuff.) 144 148 """ 145 149 146 150 def __init__(self, obj, m2m_data=None): 147 151 self.object = obj 148 152 self.m2m_data = m2m_data 149 153 150 154 def __repr__(self): 151 155 return "<DeserializedObject: %s>" % str(self.object) 152 156 153 157 def save(self, save_m2m=True): 154 158 self.object.save() … … 156 160 for accessor_name, object_list in self.m2m_data.items(): 157 161 setattr(self.object, accessor_name, object_list) 158 159 # prevent a second (possibly accidental) call to save() from saving 162 163 # prevent a second (possibly accidental) call to save() from saving 160 164 # the m2m data twice. 161 165 self.m2m_data = None django/branches/multiple-db-support/django/core/serializers/json.py
r3502 r3712 49 49 return o.strftime(self.TIME_FORMAT) 50 50 else: 51 return super( self, DateTimeAwareJSONEncoder).default(o)51 return super(DateTimeAwareJSONEncoder, self).default(o) django/branches/multiple-db-support/django/db/backends/postgresql_psycopg2/base.py
r3581 r3712 11 11 from django.core.exceptions import ImproperlyConfigured 12 12 raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e 13 14 # Register Unicode conversions15 import psycopg2.extensions16 psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)17 13 18 14 DatabaseError = Database.DatabaseError … … 48 44 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 49 45 cursor = self.connection.cursor() 46 cursor.tzinfo_factory = None 50 47 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 51 48 if settings.DEBUG: django/branches/multiple-db-support/django/db/backends/util.py
r3113 r3712 99 99 def _dict_helper(desc, row): 100 100 "Returns a dictionary for the given cursor.description and result row." 101 return dict( [(desc[col[0]][0], col[1]) for col in enumerate(row)])101 return dict(zip([col[0] for col in desc], row)) 102 102 103 103 def dictfetchone(cursor): django/branches/multiple-db-support/django/template/defaulttags.py
r3664 r3712 252 252 if self.parsed: 253 253 try: 254 t = Template(output , name=self.filepath)254 t = Template(output) 255 255 return t.render(context) 256 256 except TemplateSyntaxError, e: django/branches/multiple-db-support/django/template/__init__.py
r3664 r3712 61 61 from django.utils.functional import curry 62 62 from django.utils.text import smart_split 63 from django.dispatch import dispatcher64 from django.template import signals65 63 66 64 __all__ = ('Template', 'Context', 'RequestContext', 'compile_string') … … 140 138 141 139 class Template(object): 142 def __init__(self, template_string, origin=None , name='<Unknown Template>'):140 def __init__(self, template_string, origin=None): 143 141 "Compilation stage" 144 142 if settings.TEMPLATE_DEBUG and origin == None: … … 147 145 # came from... 148 146 self.nodelist = compile_string(template_string, origin) 149 self.name = name150 147 151 148 def __iter__(self): … … 156 153 def render(self, context): 157 154 "Display stage -- can be called many times" 158 dispatcher.send(signal=signals.template_rendered, sender=self, template=self, context=context)159 155 return self.nodelist.render(context) 160 156 … … 619 615 (The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.') 620 616 """ 621 if path == 'False': 622 current = False 623 elif path == 'True': 624 current = True 625 elif path[0].isdigit(): 617 if path[0].isdigit(): 626 618 number_type = '.' in path and float or int 627 619 try: django/branches/multiple-db-support/django/template/loader.py
r3664 r3712 77 77 handling template inheritance recursively. 78 78 """ 79 source, origin = find_template_source(template_name) 80 template = get_template_from_string(source, origin, template_name) 81 return template 79 return get_template_from_string(*find_template_source(template_name)) 82 80 83 def get_template_from_string(source, origin=None , name=None):81 def get_template_from_string(source, origin=None): 84 82 """ 85 83 Returns a compiled Template object for the given template code, 86 84 handling template inheritance recursively. 87 85 """ 88 return Template(source, origin , name)86 return Template(source, origin) 89 87 90 88 def render_to_string(template_name, dictionary=None, context_instance=None): django/branches/multiple-db-support/django/template/loader_tags.py
r3664 r3712 58 58 raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent 59 59 else: 60 return get_template_from_string(source, origin , parent)60 return get_template_from_string(source, origin) 61 61 62 62 def render(self, context): django/branches/multiple-db-support/django/test/simple.py
r3658 r3712 62 62 suite.addTest(test) 63 63 64 old_name = create_test_db(verbosity) 64 old_name = settings.DATABASE_NAME 65 create_test_db(verbosity) 65 66 management.syncdb(verbosity, interactive=False) 66 67 unittest.TextTestRunner(verbosity=verbosity).run(suite) django/branches/multiple-db-support/django/test/utils.py
r3658 r3712 1 1 import sys, time 2 2 from django.conf import settings 3 from django.db import connection, transaction3 from django.db import backend, connect, connection, connection_info, connections 4 4 5 5 # The prefix to put on the default database name when creating … … 13 13 elif hasattr(connection.connection, "set_isolation_level"): 14 14 connection.connection.set_isolation_level(0) 15 15 16 16 def create_test_db(verbosity=1, autoclobber=False): 17 17 if verbosity >= 1: 18 18 print "Creating test database..." 19 19 20 # If we're using SQLite, it's more convenient to test against an 20 21 # in-memory database. 21 22 if settings.DATABASE_ENGINE == "sqlite3": 22 23 TEST_DATABASE_NAME = ":memory:" 24 if verbosity >= 2: 25 print "Using in-memory sqlite database for testing" 23 26 else: 24 TEST_DATABASE_NAME = TEST_DATABASE_PREFIX + settings.DATABASE_NAME 25 27 if settings.TEST_DATABASE_NAME: 28 TEST_DATABASE_NAME = settings.TEST_DATABASE_NAME 29 else: 30 TEST_DATABASE_NAME = TEST_DATABASE_PREFIX + settings.DATABASE_NAME 31 32 qn = backend.quote_name 26 33 # Create the test database and connect to it. We need to autocommit 27 34 # if the database supports it because PostgreSQL doesn't allow … … 30 37 _set_autocommit(connection) 31 38 try: 32 cursor.execute("CREATE DATABASE %s" % TEST_DATABASE_NAME)39 cursor.execute("CREATE DATABASE %s" % qn(db_name)) 33 40 except Exception, e: 34 41 sys.stderr.write("Got an error creating the test database: %s\n" % e) 35 42 if not autoclobber: 36 confirm = raw_input("It appears the test database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_DATABASE_NAME)43 confirm = raw_input("It appears the test database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % db_name) 37 44 if autoclobber or confirm == 'yes': 38 45 try: 39 46 if verbosity >= 1: 40 47 print "Destroying old test database..." 41 cursor.execute("DROP DATABASE %s" % TEST_DATABASE_NAME)48 cursor.execute("DROP DATABASE %s" % qn(db_name)) 42 49 if verbosity >= 1: 43 50 print "Creating test database..." 44 cursor.execute("CREATE DATABASE %s" % TEST_DATABASE_NAME)51 cursor.execute("CREATE DATABASE %s" % qn(db_name)) 45 52 except Exception, e: 46 53 sys.stderr.write("Got an error recreating the test database: %s\n" % e) … … 49 56 print "Tests cancelled." 50 57 sys.exit(1) 51 52 connection.close() 53 old_database_name = settings.DATABASE_NAME 54 settings.DATABASE_NAME = TEST_DATABASE_NAME 58 # Close the old connection 59 connection.close() 55 60 56 # Get a cursor (even though we don't need one yet). This has 57 # the side effect of initializing the test database. 58 cursor = connection.cursor() 59 60 return old_database_name 61 # Get a cursor (even though we don't need one yet). This has
