Commit Graph

96 Commits

Author SHA1 Message Date
Tim Graham df8d8d4292 Fixed E128 flake8 warnings in django/. 2016-04-08 09:51:06 -04:00
Tim Graham 7506616f16 Refs #24215 -- Fixed Python 3.5 compatiblity for unhandled lazy ops error. 2015-09-17 10:06:52 -04:00
Caio Ariede 6a98396b9d Fixed #25246 -- Guarded against duplicate paths in AppConfig. 2015-09-02 15:27:41 -04:00
Markus Holtermann e1427cc609 Fixed #24590 -- Cached calls to swappable_setting.
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.
2015-08-27 17:06:21 +10:00
Marten Kenbeek aabb58428b Refs #23621 -- Fixed warning message when reloading models. 2015-06-30 15:00:10 -04:00
Tim Graham 7da3923ba0 Sorted imports in __init__.py files. 2015-06-27 11:53:33 -04:00
Tim Graham 7f1168e387 Removed support for Python 3.3. 2015-06-18 08:36:50 -04:00
Peter Inglesby 0688a7946a Fixed #24776 -- Improved apps.get_app_config() error message on fully-qualified package names. 2015-05-22 11:08:25 -04:00
Alex Hill 720ff740e7 Fixed #24215 -- Refactored lazy model operations
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.
2015-03-25 16:48:17 -04:00
Marten Kenbeek 888c9b6429 Fixed #24397 -- Sped up rendering multiple model states.
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.
2015-03-08 13:54:49 +01:00
Tim Graham 9033003d97 Added check_apps_ready() to Apps.get_containing_app_config() 2015-02-08 14:52:19 -05:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Tim Graham cf5b67d3a0 Removed deprecated Apps methods per deprecation timeline. 2015-01-18 18:07:41 -05:00
Tim Graham bd98926f0e Removed an obsolete comment in django/apps/config.py 2015-01-18 16:30:45 -05:00
Daniel Pyrathon fb48eb0581 Fixed #12663 -- Formalized the Model._meta API for retrieving fields.
Thanks to Russell Keith-Magee for mentoring this Google Summer of
Code 2014 project and everyone else who helped with the patch!
2015-01-06 19:25:12 -05:00
Loic Bistuer b62f72498a Improved warning message when reloading models. Refs #23621.
Thanks dfunckt and Tim Graham.
2014-10-23 01:46:04 +07:00
Loic Bistuer 8c4ca16c65 Fixed #23621 -- Warn for duplicate models when a module 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.
2014-10-23 00:55:02 +07:00
Tim Graham 8121860be4 Revert "Improved AppRegistryNotReady message."
This reverts commit 6fa9fa91a5.

Aymeric: "I chose not to talk about django.setup() here on purpose.
This will hardly always be the correct solution."
2014-10-04 13:13:54 -04:00
Collin Anderson 6fa9fa91a5 Improved AppRegistryNotReady message. 2014-10-04 08:02:22 -04:00
Aymeric Augustin b161c01c48 Fixed #22920 -- Avoid masking some exceptions.
If loading an application trigger an ImportError, the details of that
error were lost in some cases. Thanks Ben Davis for the report.
2014-09-08 23:16:50 +02:00
Aymeric Augustin a764a9ccff Checked more precisely whether the app registry is ready.
Accounted for the three stages of population: app configs, models,
ready() methods of app configs.
2014-07-12 18:49:37 +02:00
Claude Paroz 9618d68b34 Fixed #8033 -- Explained app registry error during translation setup
Thanks Tim Graham and Aymeric Augustin for the review.
2014-06-23 09:31:45 +02:00
Claude Paroz 210d0489c5 Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX warnings
Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
2014-03-08 09:57:40 +01:00
Rodolfo Carvalho 4d4e0ea461 Fixed two typos. 2014-02-15 15:16:16 +01:00
Carl Meyer 88a2d39159 Fixed #21874 -- Require Django applications to have a filesystem path.
Wherever possible this filesystem path is derived automatically from the app
module's ``__path__`` and ``__file__`` attributes (this avoids any
backwards-compatibility problems).

AppConfig allows specifying an app's filesystem location explicitly, which
overrides all autodetection based on ``__path__`` and ``__file__``. This
permits Django to support any type of module as an app (namespace packages,
fake modules, modules loaded by other hypothetical non-filesystem module
loaders), as long as the app is configured with an explicit filesystem path.

Thanks Aymeric for review and discussion.
2014-01-27 15:34:22 -07:00
Simon Charette c3881944e8 Fixed some missing/extraneous new line warnings. 2014-01-26 14:32:01 -05:00
Aymeric Augustin 4f03b718f7 Fixed #21877 -- Renamed django.apps.base to config. 2014-01-26 13:17:03 +01:00
Aymeric Augustin 3c47786cb9 Fixed #21702 -- get_model('app_label.ModelName').
Also added tests for get_model.
2014-01-26 13:01:09 +01:00
Carl Meyer 966b186981 Fixed #17304 -- Allow single-path and configured-path namespace packages as apps.
Also document the conditions under which a namespace package may or may not be
a Django app, and raise a clearer error message in those cases where it may not
be.

Thanks Aymeric for review and consultation.
2014-01-25 19:37:05 -07:00
Aymeric Augustin 2ff93e027c Fixed #21829 -- Added default AppConfigs.
Thanks Russell for the report, Marc for the initial patch, Carl for the
final review, and everyone who contributed to the design discussion.
2014-01-25 10:41:56 +01:00
Carl Meyer 29ddae7436 Fixed #21871 -- Fixed Apps.is_installed() for apps with custom label.
Thanks Aymeric for design discussion.
2014-01-24 20:07:14 -07:00
Martin Matusiak cd69db68cf Fixed typo in comment. 2014-01-15 21:24:09 +01:00
Aymeric Augustin d674fe6dee Used a regular lock for app registry population.
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.
2014-01-12 22:08:46 +01:00
Aymeric Augustin 6a320cc14a Fixed #21718 -- Renamed has_app to is_installed. 2014-01-06 22:48:41 +01:00
Aymeric Augustin f630373b92 Fixed #21711 -- Enforced unicity of model names. 2014-01-05 20:52:53 +01:00
Aymeric Augustin 1d23d766ab Renamed AppConfig.setup to ready.
Thanks Jannis and Marc for the feedback.

Fixed #21717.
2013-12-31 18:04:54 +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 5dfec4e23b Checked unicity of app config names when populating the app registry.
This check will miss duplicates until the check for duplicate labels is
added.

Refs #21679.
2013-12-31 17:29:04 +01:00
Aymeric Augustin f46603f830 Fleshed out release notes for app loading.
Fixed #21715.
2013-12-31 15:27:25 +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
Aymeric Augustin 1c242a297b Merged Apps.populate_apps() and populate_models().
After the recent series of refactorings, there's no reason to keep
two distinct methods.

Refs #21681.
2013-12-30 23:18:22 +01:00
Aymeric Augustin 966de84973 Removed postponing in Apps.populate_models.
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.
2013-12-30 23:01:00 +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 e187caa3af Added AppConfig.setup() to run setup code. 2013-12-30 22:11:16 +01:00
Aymeric Augustin d6dc88cbc1 Avoided leaking state on exceptions in populate_models(). 2013-12-30 22:10:04 +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 8cfcd801c4 Fixed stupid error in 21f22f95. 2013-12-29 20:57:03 +01:00
Aymeric Augustin d1eb362afb Removed obsolete docstring. 2013-12-29 20:45:25 +01:00