Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/django/apps/registry.py
Commit message (Collapse)AuthorAgeFilesLines
* Refs #24215 -- Fixed Python 3.5 compatiblity for ↵Tim Graham2015-09-171-0/+4
| | | | unhandled lazy ops error.
* Fixed #24590 -- Cached calls to swappable_setting.Markus Holtermann2015-08-271-0/+22
| | | | | | | | | | Moved the lookup in Field.swappable_setting to Apps, and added an lru_cache to cache the results. Refs #24743 Thanks Marten Kenbeek for the initial work on the patch. Thanks Aymeric Augustin and Tim Graham for the review.
* Refs #23621 -- Fixed warning message when reloading models.Marten Kenbeek2015-06-301-1/+1
|
* Fixed #24776 -- Improved apps.get_app_config() error ↵Peter Inglesby2015-05-221-1/+6
| | | | message on fully-qualified package names.
* Fixed #24215 -- Refactored lazy model operationsAlex Hill2015-03-251-2/+43
| | | | | | | This adds a new method, Apps.lazy_model_operation(), and a helper function, lazy_related_operation(), which together supersede add_lazy_relation() and make lazy model operations the responsibility of the App registry. This system no longer uses the class_prepared signal.
* Fixed #24397 -- Sped up rendering multiple model states.Marten Kenbeek2015-03-081-2/+5
| | | | | | | | Set apps.ready to False when rendering multiple models. This prevents that the cache on Model._meta is expired on all models after each time a single model is rendered. Prevented that Apps.clear_cache() refills the cache on Apps.get_models(), so that the wrong value cannot be cached when cloning a StateApps.
* Added check_apps_ready() to Apps.get_containing_app_config()Tim Graham2015-02-081-3/+1
|
* Sorted imports with isort; refs #23860.Tim Graham2015-02-061-1/+1
|
* Removed deprecated Apps methods per deprecation timeline.Tim Graham2015-01-191-112/+1
|
* Fixed #12663 -- Formalized the Model._meta API for ↵Daniel Pyrathon2015-01-071-0/+5
| | | | | | | retrieving fields. Thanks to Russell Keith-Magee for mentoring this Google Summer of Code 2014 project and everyone else who helped with the patch!
* Improved warning message when reloading models. Refs #23621.Loic Bistuer2014-10-221-1/+3
| | | | Thanks dfunckt and Tim Graham.
* Fixed #23621 -- Warn for duplicate models when a module ↵Loic Bistuer2014-10-221-3/+9
| | | | | | | | | | | is reloaded. Previously a RuntimeError was raised every time two models clashed in the app registry. This prevented reloading a module in a REPL; while it's not recommended to do so, we decided not to forbid this use-case by turning the error into a warning. Thanks @dfunckt and Sergey Pashinin for the initial patches.
* Revert "Improved AppRegistryNotReady message."Tim Graham2014-10-041-1/+1
| | | | | | | This reverts commit 6fa9fa91a5fcb228b3c385b35a2018b3821a447a. Aymeric: "I chose not to talk about django.setup() here on purpose. This will hardly always be the correct solution."
* Improved AppRegistryNotReady message.Collin Anderson2014-10-041-1/+1
|
* Checked more precisely whether the app registry is ready.Aymeric Augustin2014-07-121-20/+31
| | | | | Accounted for the three stages of population: app configs, models, ready() methods of app configs.
* Fixed #8033 -- Explained app registry error during ↵Claude Paroz2014-06-231-2/+2
| | | | | | translation setup Thanks Tim Graham and Aymeric Augustin for the review.
* Fixed #21188 -- Introduced subclasses for ↵Claude Paroz2014-03-081-9/+10
| | | | | | | to-be-removed-in-django-XX warnings Thanks Anssi Kääriäinen for the idea and Simon Charette for the review.
* Fixed #21877 -- Renamed django.apps.base to config.Aymeric Augustin2014-01-261-1/+1
|
* Fixed #21702 -- get_model('app_label.ModelName').Aymeric Augustin2014-01-261-2/+8
| | | | Also added tests for get_model.
* Fixed #21871 -- Fixed Apps.is_installed() for apps with ↵Carl Meyer2014-01-251-2/+1
| | | | | | custom label. Thanks Aymeric for design discussion.
* Used a regular lock for app registry population.Aymeric Augustin2014-01-121-5/+8
| | | | | | | | Since the app registry is always populated before the first request is processed, the situation described in #18251 for the old app cache cannot happen any more. Refs #18251, #21628.
* Fixed #21718 -- Renamed has_app to is_installed.Aymeric Augustin2014-01-061-1/+1
|
* Fixed #21711 -- Enforced unicity of model names.Aymeric Augustin2014-01-051-1/+0
|
* Renamed AppConfig.setup to ready.Aymeric Augustin2013-12-311-1/+1
| | | | | | Thanks Jannis and Marc for the feedback. Fixed #21717.
* Enforced unicity of app labels.Aymeric Augustin2013-12-311-1/+5
| | | | Fixed #21679.
* Made it possible to change an application's label in its ↵Aymeric Augustin2013-12-311-0/+21
| | | | | | configuration. Fixed #21683.
* Checked unicity of app config names when populating the ↵Aymeric Augustin2013-12-311-1/+12
| | | | | | | | | app registry. This check will miss duplicates until the check for duplicate labels is added. Refs #21679.
* Fleshed out release notes for app loading.Aymeric Augustin2013-12-311-3/+1
| | | | Fixed #21715.
* Removed the only_with_models_module argument of ↵Aymeric Augustin2013-12-301-21/+14
| | | | | | | | | 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.
* Merged Apps.populate_apps() and populate_models().Aymeric Augustin2013-12-301-59/+19
| | | | | | | After the recent series of refactorings, there's no reason to keep two distinct methods. Refs #21681.
* Removed postponing in Apps.populate_models.Aymeric Augustin2013-12-301-30/+6
| | | | | | | | | | To the best of my understanding, since populate_models() is now called as soon as Django starts, it cannot be called while a models module is being imported, and that removes the need for postponing. (If hell breaks loose we'll revert this commit.) Refs #21681.
* Stopped populating the app registry as a side effect.Aymeric Augustin2013-12-301-22/+22
| | | | | | | 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.
* Populated Apps instances immediately by default.Aymeric Augustin2013-12-301-6/+12
|
* Added AppConfig.setup() to run setup code.Aymeric Augustin2013-12-301-0/+3
|
* Avoided leaking state on exceptions in populate_models().Aymeric Augustin2013-12-301-5/+6
|
* Deprecated the app argument of apps.get_models.Aymeric Augustin2013-12-291-26/+21
| | | | Use app_config.get_models() instead.
* Fixed stupid error in 21f22f95.Aymeric Augustin2013-12-291-1/+1
|
* Removed obsolete docstring.Aymeric Augustin2013-12-291-2/+0
|
* Added Apps.clear_cache().Aymeric Augustin2013-12-291-8/+16
| | | | This avoid leaking implementation details to tests that swap models.
* Removed the only_installed argument of Apps.get_models.Aymeric Augustin2013-12-281-25/+7
| | | | Refs #15903, #15866, #15850.
* Changed get_model to raise an exception on errors.Aymeric Augustin2013-12-281-8/+9
| | | | | | | | | | | | 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.
* Simplified Apps.get_model and added AppConfig.get_model.Aymeric Augustin2013-12-281-14/+14
| | | | Documented them as public APIs.
* Populated non-master app registries.Aymeric Augustin2013-12-281-8/+10
| | | | | | | | 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.
* Simplified the implementation of register_model.Aymeric Augustin2013-12-281-13/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | register_model is called exactly once in the entire Django code base, at the bottom of ModelBase.__new__: new_class._meta.apps.register_model(new_class._meta.app_label, new_class) ModelBase.__new__ exits prematurely 120 lines earlier (sigh) if a model with the same name is already registered: if new_class._meta.apps.get_registered_model(new_class._meta.app_label, name): return (This isn't the exact code, but it's equivalent.) apps.register_model and apps.get_registered_model are essentially a setter and a getter for apps.all_models, and apps.register_model is the only setter. As a consequence, new_class._meta.apps.all_models cannot change in-between. Considering that name == new_class.__name__, we can conclude that register_model(app_label, model) is always called with such arguments that get_registered_model(app_label, model.__name__) returns None. Considering that model._meta.model_name == model.__name__.lower(), and looking at the implementation of register_model and get_registered_model, this proves that self.all_models[app_label] doesn't contain model._meta.model_name in register_model, allowing us to simplify the implementation.
* Avoided %r formatting on possibly unicode strings.Aymeric Augustin2013-12-271-2/+2
| | | | The u prefix looks bad on Python 2.
* Made unset_installed_apps reset the app registry state.Aymeric Augustin2013-12-261-2/+2
| | | | | | Previously the _apps/models_loaded flags could remain set to False if set_installed_apps exited with an exception, which is going to happen as soon as we add tests for invalid values of INSTALLED_APPS.
* Turned apps.ready into a property. Added tests.Aymeric Augustin2013-12-261-3/+4
|
* Beefed up the comments for AppConfig.all_models.Aymeric Augustin2013-12-261-3/+7
|
* Documented the Apps and AppConfig APIs.Aymeric Augustin2013-12-241-2/+2
|
* Renamed AppCache to Apps.Aymeric Augustin2013-12-241-0/+456
Also renamed app_cache to apps and "app cache" to "app registry". Deprecated AppCache.app_cache_ready() in favor of Apps.ready().