Commit Graph

5103 Commits

Author SHA1 Message Date
Anssi Kääriäinen 20bab2cf9d Fixed #16187 -- refactored ORM lookup system
Allowed users to specify which lookups or transforms ("nested lookus")
are available for fields. The implementation is now class based.

Squashed commit of the following:

commit fa7a7195f1
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 18 10:53:24 2014 +0200

    Added lookup registration API docs

commit eb1c8ce164
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Tue Jan 14 18:59:36 2014 +0200

    Release notes and other minor docs changes

commit 11501c29c9
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Jan 12 20:53:03 2014 +0200

    Forgot to add custom_lookups tests in prev commit

commit 83173b960e
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Jan 12 19:59:12 2014 +0200

    Renamed Extract -> Transform

commit 3b18d9f3a1
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Jan 12 19:51:53 2014 +0200

    Removed suggestion of temporary lookup registration from docs

commit 21d0c7631c
Merge: 2509006 f2dc442
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Jan 12 09:38:23 2014 -0800

    Merge pull request #2 from mjtamlyn/lookups_3

    Reworked custom lookups docs.

commit f2dc4429a1
Author: Marc Tamlyn <marc.tamlyn@gmail.com>
Date:   Sun Jan 12 13:15:05 2014 +0000

    Reworked custom lookups docs.

    Mostly just formatting and rewording, but also replaced the example
    using ``YearExtract`` to  use an example which is unlikely to ever be
    possible directly in the ORM.

commit 2509006506
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Jan 12 13:19:13 2014 +0200

    Removed unused import

commit 4fba5dfaa0
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 11 22:34:41 2014 +0200

    Added docs to index

commit 6d53963f37
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 11 22:10:24 2014 +0200

    Dead code removal

commit f9cc039007
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 11 19:00:43 2014 +0200

    A new try for docs

commit 33aa18a6e3
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 11 14:57:12 2014 +0200

    Renamed get_cols to get_group_by_cols

commit c7d5f8661b
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 11 14:45:53 2014 +0200

    Altered query string customization for backends vendors

    The new way is trying to call first method 'as_' + connection.vendor.
    If that doesn't exist, then call as_sql().

    Also altered how lookup registration is done. There is now
    RegisterLookupMixin class that is used by Field, Extract and
    sql.Aggregate. This allows one to register lookups for extracts and
    aggregates in the same way lookup registration is done for fields.

commit 90e7004ec1
Merge: 66649ff f7c2c0a
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 11 13:21:01 2014 +0200

    Merge branch 'master' into lookups_3

commit 66649ff891
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Jan 11 13:16:01 2014 +0200

    Some rewording in docs

commit 31b8faa627
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Dec 29 15:52:29 2013 +0200

    Cleanup based on review comments

commit 1016159f34
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Dec 28 18:37:04 2013 +0200

    Proof-of-concept fix for #16731

    Implemented only for SQLite and PostgreSQL, and only for startswith
    and istartswith lookups.

commit 193cd097ca
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Dec 28 17:57:58 2013 +0200

    Fixed #11722 -- iexact=F() produced invalid SQL

commit 08ed3c3b49
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Dec 21 23:59:52 2013 +0200

    Made Lookup and Extract available from django.db.models

commit b99c8d83c9
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Dec 21 23:06:29 2013 +0200

    Fixed review notes by Loic

commit 049eebc070
Merge: ed8fab7 b80a835
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Dec 21 22:53:10 2013 +0200

    Merge branch 'master' into lookups_3

    Conflicts:
    	django/db/models/fields/__init__.py
    	django/db/models/sql/compiler.py
    	django/db/models/sql/query.py
    	tests/null_queries/tests.py

commit ed8fab7fe8
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Dec 21 22:47:23 2013 +0200

    Made Extracts aware of full lookup path

commit 27a57b7aed
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Dec 1 21:10:11 2013 +0200

    Removed debugger import

commit 074e0f5aca
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Dec 1 21:02:16 2013 +0200

    GIS lookup support added

commit 760e28e72b
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Dec 1 20:04:31 2013 +0200

    Removed usage of Constraint, used Lookup instead

commit eac4776684
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Dec 1 02:22:30 2013 +0200

    Minor cleanup of Lookup API

commit 2adf50428d
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sun Dec 1 02:14:19 2013 +0200

    Added documentation, polished implementation

commit 32c04357a8
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Nov 30 23:10:15 2013 +0200

    Avoid OrderedDict creation on lookup aggregate check

commit 7c8b3a32cc
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Nov 30 23:04:34 2013 +0200

    Implemented nested lookups

    But there is no support of using lookups outside filtering yet.

commit 4d219d4cde
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Wed Nov 27 22:07:30 2013 +0200

    Initial implementation of custom lookups
2014-01-18 11:46:19 +02:00
JustinTArthur 298a2b577f Adjusted inspectdb management command to yield PEP 8-compliant output barring Django Coding Style exceptions. 2014-01-17 18:03:16 -05:00
Andrew Godwin 86e69bf3b6 Fixed #21785: Bad handling of both auto_now and _add on deconstruct 2014-01-17 10:46:03 +00:00
Marc Tamlyn 2607fa9016 Fixed #21774 -- Isolate all test urls from eachother.
This (nearly) completes the work to isolate all the test modules from
each other. This is now more important as importing models from another
module will case PendingDeprecationWarnings if those modules are not in
INSTALLED_APPS. The only remaining obvious dependencies are:

- d.c.auth depends on d.c.admin (because of the is_admin flag to some
  views), but this is not so important and d.c.admin is in
  always_installed_apps
- test_client_regress depends on test_client. Eventually these should
  become a single module, as the split serves no useful purpose.
2014-01-14 15:43:27 +00:00
Marc Tamlyn 22198e6ce5 Be more careful about closing connections in mail tests. 2014-01-12 23:39:44 +00:00
Marc Tamlyn 9d2c5b0420 Undelete the `return True` removed in 4e0a2fe.
This is quite important otherwise we don't close our connections to the
SMTP server.
2014-01-12 23:38:28 +00:00
Aymeric Augustin d562527a16 Fixed #21477 -- Renamed db to using in pre/post_migrate signals. 2014-01-12 22:24:33 +01:00
Aymeric Augustin 225a6ed2cf Fixed a test that was failing with PostGIS.
Fixed #21452 again.

Forward-port of 18d75e07 from stable/1.6.x.
2014-01-12 21:40:22 +01:00
Aymeric Augustin 720c6d3a44 Restored a test broken by overzealous PEP8 cleanup 2014-01-12 21:13:32 +01:00
Simon Charette c726598c3d Fixed flake8 issues. 2014-01-12 13:40:37 -05:00
Florian Apolloner 56ab5f52c7 Merge pull request #2163 from apollo13/signals
Signals
2014-01-12 09:43:41 -08:00
Aymeric Augustin 1afe748832 Fixed #21452 -- Non-autocommit connections to PostgreSQL.
When settings.DATABASES['default']['AUTOCOMMIT'] = False, the connection
wasn't in autocommit mode but Django pretended it was.

Thanks Anssi for analysing this issue.

Refs #17062.
2014-01-12 18:28:51 +01:00
Aymeric Augustin 1c24096f1e Fixed a test isolation issue. Refs #17062.
This test could change settings.DATABASES['default']['TIME_ZONE'] and
didn't restore the previous value.
2014-01-12 18:28:51 +01:00
Anssi Kääriäinen 9918c11114 Fixed #21413 -- resolve_columns fields misalignment 2014-01-12 18:07:39 +02:00
Aymeric Augustin 9cc3371a0f Fixed #21756 -- Skipped two timezone-related tests on Windows.
Windows cannot use a time zone other than the default time zone.

Thanks manfre for the report.
2014-01-12 09:41:57 +01:00
Claude Paroz 0179852d7f Fixed #8898 -- Obsoleted SplitDateTimeWidget usage with DateTimeField
Thanks Tim Graham for the review.
2014-01-11 15:50:34 +01:00
Claude Paroz 18374c1d8c Fixed #21752 -- Prevented custom widget step attribute to be overwritten
Thanks orcein at gmail.com for the report.
2014-01-11 14:08:04 +01:00
Aymeric Augustin 3326a412cc Deprecated importing a model before loading its application.
Refs #21719, #21680.
2014-01-10 23:43:10 +01:00
Unai Zalakain 9eb16031ca Fixed #12571 -- Attached originating WSGIRequest to test client responses.
Originating WSGIRequests are now attached to the ``wsgi_request`` attribute of
the ``HttpResponse`` returned by the testing client.

Thanks rvdrijst for the suggestion.
2014-01-09 18:50:03 -05:00
Florian Apolloner 52cad43bc3 Fixed removal of signal receivers in Python 3.4
Make use of `weakref.finalize` and `weakref.WeakMethod` on python 3.4.
Simplified the removal of receivers, the old function looked overly
complicated.

Many thanks go to Antoine Pitrou for helping me to debug and explain all
the failures I ran into while writing that patch.
2014-01-09 09:27:54 +01:00
Andrew Godwin 9ae17d994b Make test stronger to hopefully fix odd Jenkins failure 2014-01-08 21:20:29 +00:00
Anssi Kääriäinen fa250c2cf9 Merge pull request #2151 from manfre/ticket-21746
Fixed #21746 - Fixed test_get_reverse_on_unsaved_object test.
2014-01-08 08:08:02 -08:00
Michael Manfre 1dbbdb29a0 Fixed #21746 - Fixed test_get_reverse_on_unsaved_object test.
Test will no longer attempt to insert multiple NULL rows in to a unique
field if the database doesn't support it.
2014-01-08 10:52:13 -05:00
Michael Manfre 8845ab62f5 Fixed #21745 - Feature check UniqueTest.test_unique_null 2014-01-08 09:53:40 -05:00
Andrew Godwin 64887c644a Fixed #21142: Dependency failures on unmigrated apps. 2014-01-08 13:00:12 +00:00
Aymeric Augustin 6a320cc14a Fixed #21718 -- Renamed has_app to is_installed. 2014-01-06 22:48:41 +01:00
Aymeric Augustin f5f7617167 Renamed a couple models to prevent duplicate names. 2014-01-05 20:52:46 +01:00
Aymeric Augustin 5d9da7597e Fixed app registry cleanup in app-loading tests. 2014-01-05 20:52:46 +01:00
Aymeric Augustin d4b059d3eb Fixed test for models in non-installed apps.
Models are now attached to any application they're defined in. Since
not_installed was inside app_loading, these models were mistakenly
attached to app_loading. The test that used them passed accidentally
when run after EggLoadingTest because that class' tearDown() method
replaces apps.all_models['app_loading'] by a copy of itself, while
it should remain the same as apps.app_configs['app_loading'].models.
2014-01-05 20:52:46 +01:00
Aymeric Augustin a7588e2e22 Removed useless model definitions.
Surprisingly, this commit doesn't change any behavior at all. When a
model is defined with the same name as another model in the same app,
the definition of the first class is bound to the name of the class
regardless of the definition of the second class.
2014-01-05 20:52:46 +01:00
Claude Paroz 196f0a356d Suppressed ResourceWarning in files tests 2014-01-03 13:37:14 +01:00
Florian Apolloner 3bc6b18cb9 Fixed selenium failure.
This fixes (at least according to tests on the ci itself)
admin_widgets.tests.RelatedFieldWidgetSeleniumFirefoxTests.test_foreign_key_using_to_field

(http://ci.djangoproject.com/job/Django/database=mysql_gis,python=python2.7/3792/testReport/junit/admin_widgets.tests/RelatedFieldWidgetSeleniumFirefoxTests/test_foreign_key_using_to_field/)

The cause for this issue seems to be that wait_page_loaded was executed before click fired
and as such no profile got saved (again just an educated guess, but with this fix I can no
longer reproduce it -- fingers crossed).
2014-01-03 11:29:37 +01:00
Florian Apolloner 7d0a519032 Revert "Fixed #21227 -- Added workaround for selenium test failures"
This reverts commit 08c9ab5a0f.
2014-01-03 00:44:49 +01:00
Florian Apolloner ed2828f0a0 Fixed a few flaky selenium tests.
Many thanks go to David Burns (@AutomatedTester) for helping me understand
css selectors and pointing me towards the correct selenium methods.
2014-01-03 00:36:50 +01:00
Claude Paroz b2d78939d1 Prevented calling setup() inside catch_warnings
When django.setup() (and then configure_logging) is called inside
catch_warnings, logging setup is negatively affected (notably
warnings.showwarning definition).
2014-01-01 22:59:12 +01:00
Aymeric Augustin 0ce945a671 Fixed #21018 -- Reversed precedence order for management commands. 2014-01-01 18:11:15 +01:00
Preston Timmons 2139e09d83 Removed unused function in test_runner tests
This was used for python 2.6 and unittest2 compatibility. It was
forgotten when the code that used it was removed.
2014-01-01 12:41:43 +01:00
Preston Timmons 18d962f2e6 Fixed #21206 -- Fixed test discovery without labels
Added test to verify an empty label performs discovery on the current
working directory.
2014-01-01 12:40:16 +01:00
Loic Bistuer 4befb3015c Fixed #21581 -- Fixed a number of issues with collectstatic.
When STATIC_ROOT wasn't set, collectstatic --clear would delete
every files within the current directory and its descendants.

This patch makes the following changes:

Prevent collectstatic from running if STATIC_ROOT isn't set.

Fixed an issue that prevented collectstatic from displaying the
destination directory.

Changed the warning header to notify when the command is run
in dry-run mode.
2013-12-31 14:58:49 -05:00
Claude Paroz b8e3373f45 Fixed #21714 -- Moved logging configuration to global setup()
Thanks Aymeric Augustin for the report and the review.
2013-12-31 18:35:00 +01:00
Aymeric Augustin 63137a8304 Enforced unicity of app labels.
Fixed #21679.
2013-12-31 18:04:54 +01:00
Aymeric Augustin c40209dcc0 Made it possible to change an application's label in its configuration.
Fixed #21683.
2013-12-31 17:30:58 +01:00
Aymeric Augustin 553500133c Removed an obsolete unicity check.
It doesn't account for app configs.

Refs #21679.
2013-12-31 17:29:04 +01:00
Claude Paroz 587b678d41 Made DeprecationDisplayTest more robust 2013-12-31 13:12:53 +01:00
Claude Paroz 1fb873cd6b Finished renaming syndication to syndication_tests 2013-12-31 11:56:41 +01:00
Claude Paroz 0b825adcf2 Renamed syndication tests
To resolve the conflict between application names.
2013-12-31 11:25:02 +01:00
Aymeric Augustin bfcc686d22 Removed the only_with_models_module argument of get_model[s].
Now that the refactorings are complete, it isn't particularly useful any
more, nor very well named. Let's keep the API as simple as possible.

Fixed #21689.
2013-12-30 23:59:34 +01:00
Florian Apolloner df075c7489 Merge pull request #2126 from apollo13/email_bytes
Many thanks to @bitdancer and @aaugustin for answering my stupid questions about (mail)encodings and pointing me in the right direction.
2013-12-30 14:58:49 -08:00
Florian Apolloner c988745cca Changed console and filebackend to use msg.as_bytes to output the data as it would get send via smtp. 2013-12-30 23:46:05 +01:00
Aymeric Augustin 80d74097b4 Stopped populating the app registry as a side effect.
Since it triggers imports, it shouldn't be done lightly.

This commit adds a public API for doing it explicitly, django.setup(),
and does it automatically when using manage.py and wsgi.py.
2013-12-30 22:11:17 +01:00
Aymeric Augustin 7ed20e0153 Populated Apps instances immediately by default. 2013-12-30 22:11:17 +01:00
Aymeric Augustin 34a215d506 Deprecated the app argument of apps.get_models.
Use app_config.get_models() instead.
2013-12-29 21:48:58 +01:00
Aymeric Augustin e5bcd1d455 Changed get_validation_errors to use an app config. 2013-12-29 21:48:58 +01:00
Aymeric Augustin 1d4bcb86ea Changed sql_* to use an app config instead of a models module. 2013-12-29 21:25:28 +01:00
Aymeric Augustin 38ce41103f Used Apps.clear_cache() in tests that alter the app registry. 2013-12-29 21:25:28 +01:00
Aymeric Augustin 00110904ac Refactored the migration signals to use app configs.
De-aliased pre/post_syncdb to pre/post_migrate to increase
backwards-compatibility.
2013-12-29 17:53:42 +01:00
Claude Paroz 6d66ba5948 Fixed #21242 -- Allowed more IANA schemes in URLValidator
Thanks Sascha Peilicke for the report and initial patch, and
Tim Graham for the review.
2013-12-28 21:25:32 +01:00
Aymeric Augustin 9f13c33281 Removed the only_installed argument of Apps.get_models.
Refs #15903, #15866, #15850.
2013-12-28 20:54:26 +01:00
Aymeric Augustin ba7206cd81 Changed get_model to raise an exception on errors.
Returning None on errors required unpythonic error checking and was
inconsistent with get_app_config.

get_model was a private API until the previous commit, but given that it
was certainly used in third party software, the change is explained in
the release notes.

Applied the same change to get_registered_model, which is a new private
API introduced during the recent refactoring.
2013-12-28 20:53:00 +01:00
Aymeric Augustin 81354b82bf Stopped calling apps.get_model with only_installed=False.
ContentTypes are only created for installed applications, and I could
make a case for not returning a model that isn't installed any more.
The check for stale ContentTypes in update_contenttypes doesn't use
model_class.

ModelSignal actually needs get_registered_model since the lookup happens
at import time. I took this opportunity to perform a small refactoring.
2013-12-28 20:42:58 +01:00
Aymeric Augustin bbdf01e00a Populated non-master app registries.
This removes the gap between the master app registry and ad-hoc app
registries created by the migration framework, specifically in terms
of behavior of the get_model[s] methods.

This commit contains a stealth feature that I'd rather not describe.
2013-12-28 20:37:42 +01:00
Florian Apolloner 5dfd824d38 Introduced as_bytes for SafeMIMEText (and other SafeMIME-classes).
This is to provide a consistent interface (namely bytes) for the smtp
backend which after all sends bytes over the wire; encoding with as_string
yields different results since mails as unicode are not really specified.

as_string stays for backwardscompatibilty mostly and some debug outputs.
But keep in mind that the output doesn't match as_bytes!
2013-12-28 18:35:17 +01:00
ijl 71a03e01aa Fixed #20346 -- Made cache middleware vary on the full URL.
Previously, only the URL path was included in the cache key.

Thanks jamey for the suggestion.
2013-12-28 11:20:18 -05:00
Aymeric Augustin c81fae6b95 Used app_label instead of appname.
The last component of the dotted path to the application module is
consistently referenced as the application "label". For instance it's
AppConfig.label. appname could be confused with AppConfig.name, which is
the full dotted path.
2013-12-28 09:53:02 +01:00
Aymeric Augustin a7add2f296 Migrated built-in AppCommands to use handle_app_config. 2013-12-28 09:43:06 +01:00
Ramiro Morales 3518e9ec1f Amend test table name so it doesn't clash.
Refs #21692 and 3efd1b8b93.
2013-12-27 21:02:39 -03:00
Ramiro Morales 3efd1b8b93 Fixed #21692 -- Quote table name when creating it. 2013-12-27 18:43:52 -03:00
Aymeric Augustin 40b8767635 Fixed a couple flake8 warnings. 2013-12-27 21:06:28 +01:00
Aymeric Augustin 8779aa806e Added a test for Apps.has_app. 2013-12-26 20:39:28 +01:00
Aymeric Augustin cfbdd587f6 Added file forgotten in previous commit, plus one more test. 2013-12-26 19:29:32 +01:00
Aymeric Augustin e179291fa5 Added tests for invalid values of INSTALLED_APPS. 2013-12-26 19:25:09 +01:00
Aymeric Augustin 8925aaf613 Added basic tests for get_app_config[s]. 2013-12-26 19:21:02 +01:00
Preston Timmons aef019de61 Fixed #21206 -- No longer run discovery if the test label doesn't point to a package or directory.
Thanks thepapermen for the report and Carl Meyer for the review.
2013-12-26 11:26:24 -05:00
Aymeric Augustin 52325b0a04 Turned apps.ready into a property. Added tests. 2013-12-26 15:04:58 +01:00
Aymeric Augustin 8f04f53dd8 Removed a few gratuitous lambdas. 2013-12-26 14:03:50 +01:00
Levi Gross 0dd9075622
Fixed unittest typo 2013-12-25 12:18:14 -05:00
Alex Gaynor dbe2fb632d Added a missing import and removed an unneeded import 2013-12-24 08:35:13 -08:00
Aymeric Augustin 1716b7ce5a Renamed AppCache to Apps.
Also renamed app_cache to apps and "app cache" to "app registry".

Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
2013-12-24 12:25:17 +01:00
Aymeric Augustin 82a35e24d4 Replaced ad-hoc caching of get_models with lru_cache.
Invalidate properly the cache whenever all_models or app_configs change.
This fixes some isolation issues in the test suite.
2013-12-24 10:56:50 +01:00
Aymeric Augustin 7577d03809 Renamed two tests so they actually run. 2013-12-23 23:54:44 +01:00
Aymeric Augustin e32095616c Imported override_settings from its new location. 2013-12-23 21:37:56 +01:00
Aymeric Augustin da16bb30ff Dropped AppCache._empty, _with_app and _without_app.
It's now easier to achieve the same effect with modify_settings or
override_settings.
2013-12-23 21:37:56 +01:00
Aymeric Augustin 5241763c81 Added modify_settings to alter settings containing lists of values. 2013-12-23 21:37:43 +01:00
Aymeric Augustin 5891990b6e Refactored INSTALLED_APPS overrides.
* Introduced [un]set_installed_apps to handle changes to the
  INSTALLED_APPS setting.
* Refactored [un]set_available_apps to share its implementation
  with [un]set_installed_apps.
* Implemented a receiver to clear some app-related caches.
* Removed test_missing_app as it is basically impossible to reproduce
  this situation with public methods of the new app cache.
2013-12-23 20:15:08 +01:00
Aymeric Augustin 3a30b9c575 Fixed a flaky test. 2013-12-22 20:22:56 +01:00
Aymeric Augustin 046a8eb9c4 Made apps available for loading traslations in a test. 2013-12-22 19:04:08 +01:00
Aymeric Augustin 865603780b Moved a test that didn't require Selenium. 2013-12-22 18:50:49 +01:00
Aymeric Augustin 690d1cb8d0 Made AppConfig importable from django.apps.
It is a public API.
2013-12-22 11:39:55 +01:00
Aymeric Augustin 2fef9e5375 Moved apps back in the toplevel django namespace.
Reverted 4a56a93cc4.
2013-12-22 11:39:55 +01:00
Aymeric Augustin 99bd39ef6e Added the ability to supply custom app configs. 2013-12-22 11:39:18 +01:00
Aymeric Augustin 517c24bcfa Complained on override_settings(INSTALLED_APPS=...).
Currently such overrides aren't reflected in the app cache.

It would  be possible to handle them. But that doesn't look like a very
good API. It makes it complicated to express "add this app" and "remove
this app", which are the most common operations on INSTALLED_APPS.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 16aae35ca8 Improved set_available_apps() in several ways.
- Tested consistency the current app_configs instead of INSTALLED_APPS.
- Considered applications added with _with_app as available.
- Added docstrings.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 2239081ff1 Expurged INSTALLED_APPS from code and tests.
Except the app cache code and a few specific tests, of course.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 9cdf1f6d54 Stop testing for inclusion in INSTALLED_APPS.
Removed some exception masking in the comments app that was harmful and
couldn't be preserved easily.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 65cd74be8e Stopped iterating on INSTALLED_APPS.
Used the app cache's get_app_configs() method instead.
2013-12-22 11:39:18 +01:00
Aymeric Augustin f25fa9d859 Deprecated load_app().
Adjusted several tests that used it to add apps to the app cache and
then attempted to remove them by manipulating attributes directly.

Also renamed invalid_models to invalid_models_tests to avoid clashing
application labels between the outer and the inner invalid_models
applications.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 86804ab063 Terminated AppCache._populate() with extreme prejudice.
It was called _populate() before I renamed it to populate(). Since it
has been superseded by populate_models() there's no reason to keep it.

Removed the can_postpone argument of load_app() as it was only used by
populate(). It's a private API and there's no replacement. Simplified
load_app() accordingly. Then new version behaves exactly like the old
one even though it's much shorter.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 2b56d69102 Implemented two-stage app-cache population.
First stage imports app modules. It doesn't catch import errors. This
matches the previous behavior and keeps the code simple.

Second stage import models modules. It catches import errors and retries
them after walking through the entire list once. This matches the
previous behavior and seems useful.

populate_models() is intended to be equivalent to populate(). It isn't
wired yet. That is coming in the next commit.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 9b3389b726 Removed the app_config.installed flag.
Since applications that aren't installed no longer have an application
configuration, it is now always True in practice.

Provided an abstraction to temporarily add or remove applications as
several tests messed with app_config.installed to achieve this effect.
For now this API is _-prefixed because it looks dangerous.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 972babc3b4 Removed the only_installed argument of get_app_config[s].
It wasn't used anywhere and couldn't be implemented any more since
non-installed apps no longer have a configuration.
2013-12-22 11:39:17 +01:00