Changeset 4125
- Timestamp:
- 11/27/06 21:45:50 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/multiple-db-support/django/core/management.py
r4123 r4125 293 293 294 294 # Install each app 295 pending = None 295 296 for app in models.get_apps(): 296 297 # Install each application (models already installed will be skipped) 297 created = _install(app, commit=False, initial_data=False) 298 created, pending = _install(app, commit=False, initial_data=False, 299 pending_allowed=True, pending=pending) 298 300 if verbosity >= 2: 299 301 for model in created: 300 302 print "Created table %s" % model._meta.db_table 301 303 created_models.extend(created) 304 if pending: 305 transaction.rollback_unless_managed() 306 raise Exception("All apps were installed, but there were still " 307 "pending references to: " + ",".join(pending.keys()) + 308 ". Transaction rolled back.") 302 309 transaction.commit_unless_managed() 303 310 … … 384 391 _install(app) 385 392 386 def _install(app, commit=True, initial_data=True): 393 def _install(app, commit=True, initial_data=True, pending_allowed=False, 394 pending=None): 387 395 from django.db import connection, models, transaction 388 396 import sys … … 397 405 created_models = [] 398 406 try: 399 pending = {} 407 if pending is None: 408 pending = {} 400 409 for model in models.get_models(app, creation_order=True): 401 410 manager = model._default_manager … … 418 427 statement.execute() 419 428 pending.pop(model) 420 el se:429 elif not pending_allowed: 421 430 raise Exception("%s is not installed, but it has pending " 422 431 "references" % model) … … 434 443 if commit: 435 444 transaction.commit_unless_managed() 436 return created_models 445 return created_models, pending 437 446 install.help_doc = "Executes ``sqlall`` for the given app(s) in the current database." 438 447 install.args = APP_ARGS
