Commit Graph

16722 Commits

Author SHA1 Message Date
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 54790e669d Simplified Apps.get_model and added AppConfig.get_model.
Documented them as public APIs.
2013-12-28 20:43:29 +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
Tim Graham 81a5e35c8d Fixed doc indentation in previous commit. 2013-12-28 11:33:24 -05: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
Florian Apolloner 280c1a65cc Worked around a bug in python 3.3.3. Refs #21093 2013-12-28 15:25:16 +01:00
Ramiro Morales 6a6136141b Implemented #10164 for new schema migration code.
Made it use 'AUTOINCREMENT' suffix for PK creation. This way it doeesn't
regress when compared with the 'traditional' DB backend creation
infrastructure.

Refs #10164.
2013-12-28 11:21:01 -03:00
Florian Apolloner f28ea02308 Fixed #21093 -- Ensured that mails are not base64 encoded on python 3.3.3+.
Thanks to Arfrever for the report and Aymeric for the review.
2013-12-28 12:42:33 +01:00
Claude Paroz b7a7baa554 Fixed #21618 -- Added hints about openlayers.js hosting
Thanks kz26 for the report and Tim Graham for the excellent
review.
2013-12-28 11:08:50 +01: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
Aymeric Augustin bb8ec71f61 Updated the AppCommand API to support apps without a models module. 2013-12-28 09:42:59 +01:00
Aymeric Augustin aff57793b4 Simplified the implementation of register_model.
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.
2013-12-28 09:34:46 +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 61cfcec5b7 Merge pull request #2120 from ramiro/schema-creation-quoting
Fixed #21692 -- Quote table name when creating it.
2013-12-27 15:40:52 -08:00
Aymeric Augustin 14bcbd9937 Avoided %r formatting on possibly unicode strings.
The u prefix looks bad on Python 2.
2013-12-27 23:19:23 +01:00
Ramiro Morales 3efd1b8b93 Fixed #21692 -- Quote table name when creating it. 2013-12-27 18:43:52 -03:00
Aymeric Augustin efddae252c Refactored dumpdata with app configs instead of models modules. 2013-12-27 21:25:35 +01:00
Aymeric Augustin 40b8767635 Fixed a couple flake8 warnings. 2013-12-27 21:06:28 +01:00
Tim Graham 85270ef3f5 Fixed #21650 -- Corrected bad advice for plural translation.
Thanks nedbatchelder and claudep.
2013-12-27 10:02:22 -05:00
Aymeric Augustin 2504a50cc2 Created a constant for the migrations module name.
Mostly for consistency with MODELS_MODULE_NAME; it's unlikely to change.
2013-12-27 15:36:19 +01:00
Florian Apolloner f00243f36d Don't try to load app directory templates from apps with a path (eg eggs) 2013-12-27 11:42:24 +01:00
Florian Apolloner 6aa1a31660 Properly app_template_dirs when INSTALLED_APPS change. 2013-12-27 11:17:25 +01:00
Tim Graham 025ec2e7fe Fixed #21582 -- Corrected URL namespace example.
Thanks oubiga for the report.
2013-12-26 20:04:28 -05:00
Aymeric Augustin 6e3ca6507c Used app_config.verbose_name instead of app_label|capfirst.
An admin view performed the capitalization in the template, unlike all others.

Refs #10436.
2013-12-26 22:58:37 +01:00
Tim Graham d8d83777eb Fixed #21629 -- Added instructions for loading MySQL time zone definitions.
Thanks Aymeric for the suggestion.
2013-12-26 15:50:33 -05:00
Aymeric Augustin 8779aa806e Added a test for Apps.has_app. 2013-12-26 20:39:28 +01:00
Tim Graham d430f1d98b Fixed #21609 -- Amended CONTRIBUTING.rst pull request guidelines.
Thanks cjerdonek for the suggestion.
2013-12-26 13:41:03 -05: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 b355e98a50 Normalized exceptions raised by AppConfig.create.
It raises ImportError whenever an entry in INSTALLED_APPS points
(directly or indirectly via AppConfig.name) to a non-existing module
and ImproperlyConfigured in all other cases.

Catching ImportError and re-raising ImproperlyConfigured tends to make
circular imports more difficult to diagnose.
2013-12-26 19:25:09 +01:00
Aymeric Augustin ce1bc2c94b Made the AppConfig API marginally more consistent.
Eliminated the app_ prefix that was more confusing than useful.
2013-12-26 19:25:09 +01:00
Aymeric Augustin fec5330c79 Made unset_installed_apps reset the app registry state.
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.
2013-12-26 19:21:02 +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 922430177c Beefed up the comments for AppConfig.all_models. 2013-12-26 14:12:30 +01:00
Aymeric Augustin 8f04f53dd8 Removed a few gratuitous lambdas. 2013-12-26 14:03:50 +01:00
Tim Graham 4e7aa573ec Added missing newline in previous commit. 2013-12-26 07:52:31 -05:00
Jon Lønne 398642fd9b Fixed #21627 -- Added unicode_literals to changepassword command.
Fixed a crash when executing changepassword command when the user object
representation contained non-ASCII characters.
2013-12-26 07:35:50 -05:00
Claude Paroz 318cdc07de Added 1.6.2 release note for 542198c1d 2013-12-26 11:10:50 +01:00
Alex Gaynor 029acbe544 Merge pull request #2114 from levigross/master
Removed redundant line
2013-12-25 14:40:30 -08:00
Levi Gross cb488c5c35
Removed redundant line 2013-12-25 17:22:13 -05:00
Aymeric Augustin 7df049c417 Swapped app registry and app config API docs.
Thanks David Larlet for the suggestion.

Also fixed some Sphinx warnings and improved ReST markup.
2013-12-25 21:57:52 +01:00
Aymeric Augustin 08bb238eae Merge pull request #2105 from funkybob/cleanup_get_post
Used @cached_property for request.GET and COOKIES
2013-12-25 12:34:06 -08:00
Yaroslav Halchenko 80027d2c38 Unified listing of shell commands/code
- use code-block:: bash
- prefix the command with $
2013-12-25 15:19:14 -05:00
Levi Gross 0dd9075622
Fixed unittest typo 2013-12-25 12:18:14 -05:00