Commit Graph

10137 Commits

Author SHA1 Message Date
Ondrej Sika 4ac5def4a2 Simplied some code in django.conf.__init__. 2013-12-18 18:23:25 -05:00
Bouke Haarsma a39d672ec7 Fixed #21386 -- Removed admindocs dependence on sites framework
* Removed ADMIN_FOR setting and warn warning
* Group view functions by namespace instead of site
* Added a test verifying namespaces are listed

Thanks to Claude Paroz for reviewing and ideas for improvement.
2013-12-18 19:44:04 +01:00
Baptiste Mispelon f1b3ab9c21 Fixed #11629 -- Deprecated callable arguments to queryset methods.
Callable arguments were an untested and undocumented feature.
2013-12-18 18:40:00 +01:00
Denis Moskalets d4e578d0f6 Fixed #21552 -- Allowed the use of None for the iexact lookup.
Thanks Anubhav Joshi for the documentation.
2013-12-18 09:34:53 -05:00
Loic Bistuer 2fd7fc134c Refs #17413 -- Added isinstance backward compatibility on ErrorList. 2013-12-18 08:59:53 -05:00
Aymeric Augustin 9bfdad5472 Style cleanup forgotten in second previous commit. 2013-12-17 22:24:25 +01:00
Aymeric Augustin 7eea9bf303 Normalized Model._meta.installed.
Used the information from the app cache instead of creating a duplicate
based on INSTALLED_APPS.

Model._meta.installed is no longer writable. It was a rather sketchy way
to alter private internals anyway.
2013-12-17 21:55:16 +01:00
Aymeric Augustin 0242c56fd8 Deborgified the app cache.
Improved Andrew's hack to create temporary app caches to handle
migrations. Now the main app cache has a "master" flag set to True
(which is a non-default keyword argument, thus unlikely to be used by
mistake). Other app cache instances have "master" set to False.

The only sanctioned way to access the app cache is by importing
django.core.apps.app_cache.

If you were instanciating an app cache and relying on the Borg pattern,
you'll have to refactor your code.
2013-12-17 21:53:18 +01:00
Aymeric Augustin 6e895f9e06 Removed superfluous models.py files.
Added comments in the three empty models.py files that are still needed.

Adjusted the test runner to add applications corresponding to test
labels to INSTALLED_APPS even when they don't have a models module.
2013-12-17 11:16:48 +01:00
Aymeric Augustin 4a56a93cc4 Moved the new app cache inside core. 2013-12-17 10:17:46 +01:00
Aymeric Augustin b3d5efe23f Restored deprecated aliases for functions in django.db.models.
Thanks Marc Tamlyn for the suggestion.
2013-12-17 10:17:46 +01:00
Aymeric Augustin f831da2fed Inlined trivial method that was used only once. 2013-12-17 10:17:46 +01:00
Aymeric Augustin b3e182faba Fixed incorrect decrementation of nesting_level.
Thanks Florian for catching this mistake.
2013-12-17 10:17:45 +01:00
Aymeric Augustin 30bdad1c47 Refactored old test runner to handle apps without a models module. 2013-12-17 10:17:45 +01:00
Aymeric Augustin 5ba743e262 Made it possible to create apps without a models module.
This commit reverts f44c4a5d0f and 39bbd165.

django.test.simple will be updated in a separate commit as it requires
invasive changes.
2013-12-17 10:17:45 +01:00
Aymeric Augustin 69039becde Deprecated get_app(). 2013-12-17 10:17:45 +01:00
Aymeric Augustin 2732edc5f2 Deprecated get_apps(). 2013-12-17 10:17:45 +01:00
Aymeric Augustin d44de9b933 Removed the _-prefix for populate().
Several parts of Django call get_apps() with a comment along this lines
of "this has the side effect of calling _populate()". I fail to see how
this is better than just calling populate()!
2013-12-17 10:17:45 +01:00
Aymeric Augustin ebda5800ae Simplified register_models.
Since it's never called with more than one model at a time the current
signature is needlessly complicated.
2013-12-17 10:17:45 +01:00
Aymeric Augustin e85932b54e Simplified handling of available_apps slightly.
It feels more natural for self.available_apps to contain app names (like
INSTALLED_APPS) than app labels, and this is easy to implement now.
2013-12-17 10:17:45 +01:00
Aymeric Augustin 259cd3cd41 Deprecated get_app_package, get_app_path and get_app_paths. 2013-12-17 10:17:45 +01:00
Aymeric Augustin da36d03fe6 Added get_app_configs() to iterate on app_config instances.
Refactored get_apps() to rely on that method.

This commit is fully backwards-compatible.
2013-12-17 10:17:44 +01:00
Aymeric Augustin a4cb140004 Added get_app_config() to look up app configs by label.
Refactored get_app() to rely on that method.

get_app() starts by calling _populate(), which goes through
INSTALLED_APPS and, for each app, imports the app module and attempts to
import the models module. At this point, no further imports are
necessary to return the models module for a  given app. Therefore, the
implementation of get_app() can be simplified and the safeguards for
race conditions can be removed.

Besides, the emptyOK parameter isn't used anywhere in Django. It was
introduced in d6c95e93 but not actually used nor documented, and it has
just been carried around since then. Since it's an obscure private API,
it's acceptable to stop supporting it without a deprecation path. This
branch aims at providing first-class support for applications without a
models module eventually.

For backwards-compatibility, get_app() still raises ImproperlyConfigured
when an app isn't found, even though LookupError is technically more
correct. I haven't gone as far as to preserve the exact error messages.
I've adjusted a few tests instead.
2013-12-17 10:17:44 +01:00
Aymeric Augustin c5eac3a2f6 Fleshed out AppConfig objects.
Marginally improved creation of AppConfig stubs for non-installed apps.
2013-12-17 10:17:44 +01:00
Aymeric Augustin b55282b98b Moved list of models inside AppConfig instances.
This commit is a refactoring with no change of functionality, according
to the following invariants:

- An app_label that was in app_configs and app_models stays in
  app_config and has its 'installed' attribute set to True.

- An app_label that was in app_models but not in app_configs is added to
  app_configs and has its 'installed' attribute set to True.

As a consequence, all the code that iterated on app_configs is modified
to check for the 'installed' attribute. Code that iterated on app_models
is rewritten in terms of app_configs.

Many tests that stored and restored the state of the app cache were
updated.

In the long term, we should reconsider the usefulness of allowing
importing models from non-installed applications. This doesn't sound
particularly useful, can be a trap in some circumstances, and causes
significant complexity in sensitive areas of Django.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 2c9e84af4a Removed unused attribute app_errors of the app cache.
get_app_errors() always returned an empty dictionary; this behavior is
preserved in django.db.models.loading until that module is deprecated.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 0e9d3472d7 Stored AppConfig objects instead of models modules in the app cache.
This is a step towards allowing applications without a models module.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 8662654d6d Removed module-level functions for the app cache.
Since the original ones in django.db.models.loading were kept only for
backwards compatibility, there's no need to recreate them. However, many
internals of Django still relied on them.

They were also imported in django.db.models. They never appear in the
documentation, except a quick mention of get_models and get_app in the
1.2 release notes to document an edge case in GIS. I don't think that
makes them a public API.

This commit doesn't change the overall amount of global state but
clarifies that it's tied to the app_cache object instead of hiding it
behind half a dozen functions.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 334551339d Removed ModelDict.
Its only difference with OrderedDict is that it didn't deepcopy its
keys. However it wasn't used anywhere with models modules as keys, only
as values. So this commit doesn't result in any change in functionality.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 9217b89da3 Removed BaseAppCache.app_store.
It was only storing redundant information. This is part of the effort to
allow applications without a models module.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 860c2c8bc5 Moved django.db.models.loading to django.apps.cache.
This commit doesn't contain any code changes; it's purely a refactoring.
2013-12-17 10:17:43 +01:00
Artur Barseghyan fe1389e911 Removed duplicated `TimeField` in __all__. 2013-12-16 17:52:37 -05:00
Loic Bistuer 3ce9829b61 Fixed #17413 -- Serialization of form errors along with all metadata. 2013-12-16 16:33:28 -05:00
Baptiste Mispelon e2f142030b Fixed #21564 -- Use local request object when possible in generic views.
Thanks to trac user adepue for the report and original patch.
2013-12-16 16:58:08 +01:00
Baptiste Mispelon 3eb58f0dd1 Removed unnecessary function-level import. 2013-12-16 15:30:51 +01:00
Vajrasky Kok db41778e8c Removed unnecessary call to force_text in utils.html.clean_html.
Refs #21574
2013-12-16 15:22:54 +01:00
Peter Harley cdd6617da6 Fixed #21619 -- Made SingleObjectMixin.get_object catch a more precise exception.
Thanks to Keryn Knight for the report.
2013-12-15 21:49:52 +01:00
Aymeric Augustin 3beffea4b0 Fixed #21621 -- Removed kqueue autoreloader. 2013-12-15 14:43:52 +01:00
Claude Paroz 164a3a388c Revert "Allowed running GIS form tests that don't require spatial database"
This reverts commit 07fe0bf3f4.
This was not working properly on system without geos library
installed.
2013-12-14 21:03:09 +01:00
Bartolomé Sánchez 8f994f1bcc Fixed #21250 -- Made HTTP auth user header configurable in tests
Currently, if the authentication mechanism uses a custom HTTP header
and not REMOTE_USER, it is not easy to test. This commit modifies
remote user tests in order to make them more generic.
2013-12-14 13:02:56 -05:00
Loic Bistuer 6685713869 Fixed E127 pep8 warnings. 2013-12-14 11:59:15 -05:00
Jakub Gocławski 07fe0bf3f4 Allowed running GIS form tests that don't require spatial database 2013-12-14 13:57:58 +01:00
Jakub Gocławski 2ddf1fc50f Fixed #21606 -- Fixed default_lat and default_lon override in OSMWidget 2013-12-14 13:53:37 +01:00
Baptiste Mispelon 2c837233f5 Fixed #21574 -- Handle bytes consistently in utils.text.normalize_newlines.
All input is now coerced to text before being normalized.
This changes nothing under Python 2 but it allows bytes
to be passed to the function without a TypeError under Python3
(bytes are assumed to be utf-8 encoded text).

Thanks to trac user vajrasky for the report.
2013-12-12 16:09:12 +01:00
Baptiste Mispelon b9c7234e2a Fixed PEP257 violations (single-quoted docstrings) in utils.text. 2013-12-12 16:08:59 +01:00
Ludwik Trammer 9922ed46e2 Fixed #21473 -- Limited language preservation to logout
Current language is no longer saved to session by LocaleMiddleware
on  every response (the behavior introduced in #14825).
Instead language stored in session is reintroduced into new session
after logout.

Forward port of c558a43fd6 to master.
2013-12-12 10:24:43 +01:00
Aymeric Augustin 9c5f59f489 Brought comments in sync with the code in BaseAppCache. 2013-12-11 23:16:06 +01:00
Dominic Rodger 5cd6477fd6 Fixed #21462 -- Made `assertNumQueries` print executed queries on failure. 2013-12-11 15:24:17 -05:00
Simon Charette 75924cfa6d Fixed #21563 -- Single related object descriptors should work with `hasattr`.
Thanks to Aymeric Augustin for the review and Trac alias monkut for the report.
2013-12-11 12:49:28 -05:00
Claude Paroz c7c647419c Fixed #21510 -- Readded search reset link in changelist search bar
Thanks moritz.pfeiffer at alp-phone.ch for the report and
Tim Graham for the initial patch.
2013-12-11 15:30:20 +01:00