Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#10079 closed (fixed)

Make template.context usable outside of Django

Reported by: kcarnold Owned by: gwilson
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 kcarnold 6 years ago.
10079-reusable-context.2.diff (874 bytes) - added by mcroydon 6 years ago.
10079-reusable-context.diff (681 bytes) - added by mcroydon 6 years ago.
Actually update the diff this time.

Download all attachments as: .zip

Change History (12)

Changed 6 years ago by kcarnold

comment:1 Changed 6 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by mcroydon

  • Triage Stage changed from Accepted to Ready 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 6 years ago by Alex

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 6 years ago by mcroydon

comment:4 Changed 6 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 6 years ago by mcroydon

Actually update the diff this time.

comment:5 Changed 6 years ago by gwilson

  • Owner changed from nobody to gwilson
  • Status changed from new to assigned

comment:6 Changed 6 years ago by gwilson

  • Resolution set to fixed
  • Status changed from assigned to closed

(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 6 years ago by gwilson

(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 6 years ago by gwilson

  • Summary changed from [trivial, patch] Make template.context usable outside of Django to Make template.context usable outside of Django

comment:9 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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