[Django] #24783: Template libraries and built-ins should be registered through the engine

13 views
Skip to first unread message

Django

unread,
May 11, 2015, 1:17:01 PM5/11/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+--------------------
Reporter: prestontimmons | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
Django template libraries and builtins depend on global variables in
`django.template.base`. This is messy, but also restrictive. The only way
to specify template tag modules is by adding a package in `INSTALLED_APPS`
that has a `templatetags` directory. Modifying `builtins` is a hack. And
the `LoadNode` has a hard dependency on `django.apps`. Preferably,
libraries and builtins should be specified and live on the `Engine`
instance instead.

I think this can be cleaned up by having libraries and builtins configured
via the `DjangoTemplates` backend. This would build on Mark Tamlyn's idea
in #12772:

{{{
TEMPLATES = [
{
...
'OPTIONS': {
'libraries': {
'admin.urls':
'django.contrib.admin.templatetags.admin_urls',
'my_tags': 'path.to.some.module',
},
'builtins': {
'path.to.builtins_module',
}
},
},
]
}}}

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

Django

unread,
May 12, 2015, 8:36:57 AM5/12/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------

Reporter: prestontimmons | Owner: nobody
Type: New feature | 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 timgraham):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
May 12, 2015, 5:27:47 PM5/12/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner: akulakov
Type: New feature | Status: assigned

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 akulakov):

* status: new => assigned
* owner: nobody => akulakov


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

Django

unread,
May 12, 2015, 6:38:00 PM5/12/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner: akulakov
Type: New feature | Status: assigned
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 prestontimmons):

Hi akulokov,

I have a PR close to ready on this ticket. Just wanted to let you know
since you assigned yourself, and I forgot to assign myself earlier.

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

Django

unread,
May 12, 2015, 11:35:37 PM5/12/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner: akulakov
Type: New feature | Status: assigned
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 akulakov):

@preston, no problem, unassigning myself..

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

Django

unread,
May 12, 2015, 11:36:20 PM5/12/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner:

Type: New feature | 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 akulakov):

* owner: akulakov =>
* status: assigned => new


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

Django

unread,
May 12, 2015, 11:36:46 PM5/12/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner:

Type: New feature | 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 akulakov):

* cc: andrei.avk@… (added)


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

Django

unread,
May 13, 2015, 7:09:06 PM5/13/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner:

Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* has_patch: 0 => 1


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

Django

unread,
May 18, 2015, 8:34:54 AM5/18/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner:

Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


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

Django

unread,
May 18, 2015, 8:36:19 AM5/18/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
---------------------------------+------------------------------------
Reporter: prestontimmons | Owner:

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

Comment (by timgraham):

Should we close #17085 "Deprecate "add_to_builtins" and turn builtins into
a property of Engine" as a duplicate?

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

Django

unread,
May 20, 2015, 1:34:23 PM5/20/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
-------------------------------------+-------------------------------------
Reporter: prestontimmons | Owner:

Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

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

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

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


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

Django

unread,
May 21, 2015, 11:03:09 AM5/21/15
to django-...@googlegroups.com
#24783: Template libraries and built-ins should be registered through the engine
-------------------------------------+-------------------------------------
Reporter: prestontimmons | Owner: Preston
| Timmons <prestontimmons@…>
Type: New feature | Status: closed

Component: Template system | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Preston Timmons <prestontimmons@…>):

* status: new => closed
* owner: => Preston Timmons <prestontimmons@…>
* resolution: => fixed


Comment:

In [changeset:"655f52491505932ef04264de2bce21a03f3a7cd0" 655f5249]:
{{{
#!CommitTicketReference repository=""
revision="655f52491505932ef04264de2bce21a03f3a7cd0"
Fixed #17085, #24783 -- Refactored template library registration.

* Converted the ``libraries`` and ``builtins`` globals of
``django.template.base`` into properties of the Engine class.
* Added a public API for explicit registration of libraries and builtins.
}}}

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

Reply all
Reply to author
Forward
0 new messages