0
0
mirror of https://github.com/django/django.git synced 2024-11-29 14:46:18 +01:00
Commit Graph

16601 Commits

Author SHA1 Message Date
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
Baptiste Mispelon
1689744aee Added some internal links to render_to_string documentation. 2013-12-15 23:02:20 +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
Alex Gaynor
a1bc3683ff Merge pull request #2079 from brutasse/master
Typo in 1.7 release notes
2013-12-15 07:45:12 -08:00
Aymeric Augustin
3beffea4b0 Fixed #21621 -- Removed kqueue autoreloader. 2013-12-15 14:43:52 +01:00
Andrew Godwin
dfc95d240d Fix docs typo 2013-12-15 12:11:02 +00:00
Bruno Renié
f27ed47b60 Typo in 1.7 release notes 2013-12-15 10:00:13 +01:00
Baptiste Mispelon
e904d421d0 Added internal link to i18n documentation. 2013-12-15 01:50:54 +01:00
Alasdair Nicol
1fa681ee11 Fixed #21539 -- Added example of modelformset_factory's form argument 2013-12-14 16:35:14 -05: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
Marti Raudsepp
75ec1fdf16 Clarifed table rewrites in migration docs.
Small nitpicks. All column-related ALTER TABLE commands take an
exclusive table lock in PostgreSQL. The difference is that adding a
column without default doesn't cause a table rewrite, so the lock is
held only for a short time.

The time taken is more accurately proportional to table size, not row
count.
2013-12-14 12:34:45 -05:00
Loic Bistuer
6685713869 Fixed E127 pep8 warnings. 2013-12-14 11:59:15 -05:00
Chris Jerdonek
d599b590eb Fixed #21614 -- improved docs on configuring email for development. 2013-12-14 11:20:38 -05:00
Bouke Haarsma
bed52afee7 Removed usage of to-be-deprecated ADMIN_FOR setting in contributing docs 2013-12-14 16:49:25 +01:00
Chris Jerdonek
e1cfc4b96a Fixed link text for "Testing in Django" in tutorial 5. 2013-12-14 10:41:26 -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
johannes-gehrs
f685f94c98 Fixed #21580 -- Clarified why render() does not return a TemplateResponse object. 2013-12-13 18:56:18 -05:00
Tim Graham
ccd80dc3b6 Added 1.6.2 release notes stub. 2013-12-13 18:42:24 -05:00
Tim Graham
99b7d74914 Merge pull request #2067 from dominicrodger/master
Moving notes for assertNumQueries next to the other changes to test infrastructure
2013-12-13 07:36:57 -08:00
Baptiste Mispelon
d4d0dd7416 Changed documentation of HttpResponse.content to indicate it's a bytestring 2013-12-13 11:42:14 +01:00
Tim Graham
e01ade61fe Copied 1.6.1 release notes from stable/1.6.x branch. 2013-12-12 15:08:22 -05: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