[Django] #17093: Refactor django.template to quarantine global state

18 views
Skip to first unread message

Django

unread,
Oct 23, 2011, 3:56:06 PM10/23/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
------------------------------------------------+------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
The template engine keeps a lot of global state around: the instantiated
template loaders, the list of builtins, the cached list of loaded
templatetag modules. This makes it inflexible for use as a library (you
can't render different templates using different template loaders or
directories or tag modules in the same process) and makes test isolation
very difficult (for the same reasons).

This can be fixed via a refactoring to introduce a `TemplateEngine` class
to encapsulate all this state. We would still create a default module-
level instance of `TemplateEngine` based on the settings, and backwards-
compatibility wrappers for the current public API that delegate to the
default engine. But this would then allow alternative instances of
TemplateEngine to be created and used for library use and testing, that
would be self-contained and independent from settings.

In the long run, this type of refactoring is also necessary if we want to
move towards "app-object" style configuration in place of global settings.

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

Django

unread,
Oct 23, 2011, 3:58:34 PM10/23/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Alex):

* stage: Unreviewed => Accepted


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

Django

unread,
Nov 16, 2011, 2:42:39 PM11/16/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Bradley Ayers <bradley.ayers@…>):

* cc: bradley.ayers@… (added)


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

Django

unread,
Nov 16, 2011, 5:48:36 PM11/16/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by wayla):

* cc: waylan@… (added)


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

Django

unread,
Nov 21, 2011, 5:27:58 PM11/21/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by steveire):

For an equivalent API (in C++) see
http://www.grantlee.org/apidox/classGrantlee_1_1Engine.html.

It also allows the case of pre-loading template tag modules brought up
recently on the devel mailing list.

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

Django

unread,
Dec 9, 2011, 4:48:41 PM12/9/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by anatoly techtonik <techtonik@…>):

* cc: techtonik@… (added)


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

Django

unread,
Dec 10, 2011, 10:30:53 AM12/10/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by kmike):

* cc: kmike84@… (added)


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

Django

unread,
Dec 15, 2011, 4:09:26 PM12/15/11
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by tgecho):

* cc: tgecho (added)


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

Django

unread,
Jul 1, 2012, 11:26:18 PM7/1/12
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by yac):

* cc: yac (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:8>

Django

unread,
Dec 16, 2012, 11:13:55 AM12/16/12
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner:
Type: | chrismedrela
Cleanup/optimization | Status: new

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by chrismedrela):

* owner: nobody => chrismedrela


--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:9>

Django

unread,
Jan 28, 2013, 12:32:19 PM1/28/13
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner:
Type: | chrismedrela
Cleanup/optimization | Status: new

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by anonymous):

See progress of my work at github
https://github.com/chrismedrela/django/tree/ticket_17093.

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:10>

Django

unread,
Jan 28, 2013, 12:33:23 PM1/28/13
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner:
Type: | chrismedrela
Cleanup/optimization | Status: new

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by chrismedrela):

That was me.

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:11>

Django

unread,
Jan 28, 2013, 4:30:44 PM1/28/13
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner:
Type: | chrismedrela
Cleanup/optimization | Status: new

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by chrismedrela):

I've started discussion at django-developers mailing list
https://groups.google.com/d/topic/django-
developers/WT1cOvpPbSM/discussion.

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:12>

Django

unread,
Feb 21, 2013, 10:20:39 AM2/21/13
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner:
Type: | chrismedrela
Cleanup/optimization | Status: new

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by chrismedrela):

I rebased my work. I kept old branch and created new one
(https://github.com/chrismedrela/django/tree/ticket_17093v2) where I'm
pushing my work. The branch is almost ready to review.

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:13>

Django

unread,
Feb 28, 2013, 4:53:00 PM2/28/13
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner:
Type: | chrismedrela
Cleanup/optimization | Status: new

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by chrismedrela):

Please watch new branch
(https://github.com/chrismedrela/django/tree/ticket_17093v3).

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:14>

Django

unread,
Mar 29, 2013, 2:34:43 AM3/29/13
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner:
Type: | chrismedrela
Cleanup/optimization | Status: new

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by techtonik):

What is exactly the scope of data that should encapsulated in
`TemplateEngine`, and what will be left behind?

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:15>

Django

unread,
Nov 17, 2014, 3:05:44 PM11/17/14
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner: aaugustin
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Template system | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* owner: chrismedrela => aaugustin
* status: new => assigned


Comment:

I'm picking this up as part of my Multiple Template Engines project.

See https://github.com/aaugustin/django/compare/refactor-template-engine-
as-library

I'm going to perform a more intensive cleanup and reorganisation of
django.template.

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:16>

Django

unread,
Nov 22, 2014, 4:54:45 PM11/22/14
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner: aaugustin
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Template system | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/3605

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:17>

Django

unread,
Nov 27, 2014, 3:21:11 PM11/27/14
to django-...@googlegroups.com
#17093: Refactor django.template to quarantine global state
-------------------------------------+-------------------------------------
Reporter: carljm | Owner: aaugustin
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Template system | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: assigned => closed
* resolution: => fixed


Comment:

I assume this can be closed since the PR was committed. Please reopen if
there is still more work to do.

--
Ticket URL: <https://code.djangoproject.com/ticket/17093#comment:18>

Reply all
Reply to author
Forward
0 new messages