Author: jpellerin Date: 2006-07-19 13:10:19 -0500 (Wed, 19 Jul 2006) New Revision: 3384
Modified: django/branches/multiple-db-support/tests/othertests/ansi_sql.py Log: [multi-db] Added workarounds for model-loading to allow in-module models to appear in get_models(). Modified: django/branches/multiple-db-support/tests/othertests/ansi_sql.py =================================================================== --- django/branches/multiple-db-support/tests/othertests/ansi_sql.py 2006-07-19 18:09:32 UTC (rev 3383) +++ django/branches/multiple-db-support/tests/othertests/ansi_sql.py 2006-07-19 18:10:19 UTC (rev 3384) @@ -54,14 +54,21 @@ [BoundStatement('DROP TABLE "ansi_sql_mod";')] >>> builder.get_drop_table(Car) [BoundStatement('DROP TABLE "ansi_sql_car";')] ->>> builder.get_drop_table(Car, cascade=True) -[BoundStatement('DROP TABLE "ansi_sql_car";')] +# drop with cascade >>> builder.tables = ['ansi_sql_car', 'ansi_sql_mod', 'ansi_sql_collector'] >>> Mod._default_manager.db.backend.supports_constraints = False +>>> Mod._default_manager.db.backend.supports_constraints +False +>>> Car._default_manager.db.backend.supports_constraints +False >>> builder.get_drop_table(Car, cascade=True) [BoundStatement('DROP TABLE "ansi_sql_car";')] >>> Mod._default_manager.db.backend.supports_constraints = True +>>> Mod._default_manager.db.backend.supports_constraints +True +>>> Car._default_manager.db.backend.supports_constraints +True >>> builder.get_drop_table(Car, cascade=True) [BoundStatement('ALTER TABLE "ansi_sql_mod" ...'), BoundStatement('DROP TABLE "ansi_sql_car";')] >>> builder.get_drop_table(Collector) @@ -72,9 +79,13 @@ """ import os +import sys +from django.conf import settings +from django.core.management import install from django.db import models -from django.core.management import install +from django.db.models import loading + # For Python 2.3 if not hasattr(__builtins__, 'set'): from sets import Set as set @@ -121,7 +132,16 @@ return os.path.normpath(os.path.join(os.path.dirname(__file__), 'sql')) -# install my stuff +# install my models and force myself into the registry of apps and models +# (without this, references and such to/from the models installed here +# won't be picked up in get_models(), since get_models() looks only at +# models from apps in INSTALLED_APPS, and the model and app lookup rules +# enforce a module structure that this test file can't follow) Car.objects.install() Collector.objects.install() Mod.objects.install() +loading.get_apps() +loading._app_list.append(sys.modules[__name__]) + +# model lookup only works for pk.models, so fake up my module name +__name__ = 'othertests.ansi_sql.models' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-updates -~----------~----~----~----~------~----~------~--~---