Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#10079 closed (fixed)

Make template.context usable outside of Django

Reported by: Kenneth Arnold Owned by: Gary Wilson
Component: Template system Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I needed a data structure exactly like Django's Context object for a project. Unfortunately, the whole module imports settings even though it's only needed in one place. The trivial attached patch moves the import to where it's actually needed.

Attachments (3)

dj-context-reusable.patch (770 bytes) - added by Kenneth Arnold 8 years ago.
10079-reusable-context.2.diff (874 bytes) - added by mcroydon 8 years ago.
10079-reusable-context.diff (681 bytes) - added by mcroydon 8 years ago.
Actually update the diff this time.

Download all attachments as: .zip

Change History (12)

Changed 8 years ago by Kenneth Arnold

Attachment: dj-context-reusable.patch added

comment:1 Changed 8 years ago by Jacob

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by mcroydon

Triage Stage: AcceptedReady for checkin

This is a pretty trivial patch that applies cleanly and doesn't cause any test breakage. I'm going to call this ready for checkin but please scold me if you should.

comment:3 Changed 8 years ago by Alex Gaynor

Is there any reason to move all the imports inside the function, I think we only need to move the settings import as the issue is not having all of Django on disk, it's using it in the context of a django project.

Changed 8 years ago by mcroydon

comment:4 Changed 8 years ago by mcroydon

No reason other than they were only being used inside that function and I was trying to reduce imports to fit the use case. Django should already be on his pythonpath if he's importing Context from it thought. Updated patch moves the other imports back to the top.

Changed 8 years ago by mcroydon

Attachment: 10079-reusable-context.diff added

Actually update the diff this time.

comment:5 Changed 8 years ago by Gary Wilson

Owner: changed from nobody to Gary Wilson
Status: newassigned

comment:6 Changed 8 years ago by Gary Wilson

Resolution: fixed
Status: assignedclosed

(In [10209]) Fixed #10079 -- Moved settings import inside the function that uses it so that the module can be imported without needing settings, thanks kcarnold and mcroydon.

comment:7 Changed 8 years ago by Gary Wilson

(In [10210]) [1.0.X]: Fixed #10079 -- Moved settings import inside the function that uses it so that the module can be imported without needing settings, thanks kcarnold and mcroydon.

Backport of r10209 from trunk.

comment:8 Changed 8 years ago by Gary Wilson

Summary: [trivial, patch] Make template.context usable outside of DjangoMake template.context usable outside of Django

comment:9 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top