[Django] #30536: Improve django.setup() semantic

13 views
Skip to first unread message

Django

unread,
Jun 1, 2019, 3:15:15 PM6/1/19
to django-...@googlegroups.com
#30536: Improve django.setup() semantic
------------------------------------------+------------------------
Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Keywords: setup
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
Make django.setup() idempotent, and add setting DJANGO_SETUP_CALLABLE so
that actual setup operations can be overridden in a project.

This is especially useful when testing, since test runners (eg. pytest-
django) often configure the framework by themselves, before the end user
can patch it with mockups and other early-time tweaks.

--
Ticket URL: <https://code.djangoproject.com/ticket/30536>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 1, 2019, 3:38:32 PM6/1/19
to django-...@googlegroups.com
#30536: Improve django.setup() semantic
--------------------------------+--------------------------------------

Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:

Keywords: setup | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by pascal chambon):

Pending PR on https://github.com/django/django/pull/11435.

--
Ticket URL: <https://code.djangoproject.com/ticket/30536#comment:1>

Django

unread,
Jun 3, 2019, 9:49:28 AM6/3/19
to django-...@googlegroups.com
#30536: Improve django.setup() semantic
--------------------------------+--------------------------------------
Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: duplicate

Keywords: setup | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => duplicate


Comment:

Hi Pascal. I'm going to close this as a Duplicate of #28752. Let's keep
the discussion there. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/30536#comment:2>

Django

unread,
Jun 3, 2019, 10:37:16 AM6/3/19
to django-...@googlegroups.com
#30536: Allow running custom logic in django.setup().
--------------------------------+--------------------------------------

Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:

Keywords: setup | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: closed => new
* needs_better_patch: 0 => 1
* resolution: duplicate =>


Comment:

Looking at the PR, I've re-titled this reopened it, since I could see
#28752 being accepted separately a resolution here. Can you please split
the PR into two along those lines? Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/30536#comment:3>

Django

unread,
Jun 3, 2019, 11:06:35 AM6/3/19
to django-...@googlegroups.com
#30536: Allow running custom logic in django.setup().
--------------------------------+------------------------------------
Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: setup | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

OK, I'm going to provisionally accept this.

Two use-cases seem desirable:

1. The testing example, of setting up mocks etc.
2. If #28752 were in place, having a ''project-level'' hook for Do-this-
Once setup logic might solve issues that app-level `ready()` handlers
can't.

I'm not sure about the proposed implementation. I'll ask others to review.
(Maybe we have to say `wontfix`, and stick with monkey patching `setup()`
if needs be...)

--
Ticket URL: <https://code.djangoproject.com/ticket/30536#comment:4>

Django

unread,
Jun 4, 2019, 4:52:05 PM6/4/19
to django-...@googlegroups.com
#30536: Allow running custom logic in django.setup().
--------------------------------+------------------------------------
Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: setup | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------

Comment (by pascal chambon):

Ok the PR is pending for #28752 B-)

--
Ticket URL: <https://code.djangoproject.com/ticket/30536#comment:5>

Django

unread,
Jun 23, 2019, 4:54:34 PM6/23/19
to django-...@googlegroups.com
#30536: Allow running custom logic in django.setup().
--------------------------------+------------------------------------
Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: setup | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------

Comment (by Florian Apolloner):

Replying to [comment:4 Carlton Gibson]:


> I'm not sure about the proposed implementation. I'll ask others to
review.

Same here, my comment from the PR:

Personally I feel that this fix is happening at the wrong level. An
environment variable (Or even as keyword argument to ''setup'' itself)
feels more suitable, after all ''setup'' is the thing that reads your
settings in the first place.

I think this might be something that could/should be discussed on the
mailing list?

--
Ticket URL: <https://code.djangoproject.com/ticket/30536#comment:6>

Django

unread,
Oct 17, 2019, 4:58:36 AM10/17/19
to django-...@googlegroups.com
#30536: Allow running custom logic in django.setup().
--------------------------------+------------------------------------
Reporter: pascal chambon | Owner: nobody
Type: New feature | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: wontfix

Keywords: setup | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => wontfix


Comment:

Given #28752 and the concerns raised, I'm going to say `wontfix` here.

It's easy enough to adjust an entry point script (canonically `wsgi.py`,
but whatever is in play) to run custom logic at start up.
IMO That's always going to come out cleaner than adding a settings powered
hook in here.

--
Ticket URL: <https://code.djangoproject.com/ticket/30536#comment:7>

Reply all
Reply to author
Forward
0 new messages