Code

Opened 8 years ago

Closed 6 years ago

Last modified 6 years ago

#1065 closed enhancement (fixed)

Add a template tag that allows for partial caching of templates

Reported by: deric <deric@…> Owned by: nobody
Component: Template system Version: master
Severity: normal Keywords: sprintsept14 feature
Cc: jshaffer2112@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Attachments (5)

fragment_caching.py (1.2 KB) - added by SmileyChris 7 years ago.
Ian Maurer's template tag
fragment_caching_docs.diff (1.6 KB) - added by nick.lane.au@… 7 years ago.
Added docs
fragment_caching.diff (5.7 KB) - added by nick.lane.au@… 7 years ago.
Combined patches and added some tests.
fragment_caching.2.diff (5.5 KB) - added by nick.lane.au@… 7 years ago.
Renamed template library to 'cache'
cache_tag.diff (4.3 KB) - added by zz 6 years ago.
Improved tag to accept time as variable

Download all attachments as: .zip

Change History (20)

comment:1 Changed 7 years ago by SmileyChris

  • Has patch set
  • Needs documentation set
  • Triage Stage changed from Unreviewed to Accepted

Moving Ian Maurer's post in the group discussion to this ticket since it's a great patch. Probably needs some documentation and then it's good to go.

Approving due to Adrian's comment in the discussion.

{% load fragment_caching %}
{% cache <exptime> <name> [id args..] %}

For instance...

{% load fragment_caching %}
{% cache 500 sidebar object.id %}
    .. sidebar for object ..
{% endcache %}

Changed 7 years ago by SmileyChris

Ian Maurer's template tag

Changed 7 years ago by nick.lane.au@…

Added docs

comment:2 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests set

Changed 7 years ago by nick.lane.au@…

Combined patches and added some tests.

Changed 7 years ago by nick.lane.au@…

Renamed template library to 'cache'

comment:3 Changed 7 years ago by nick.lane.au@…

I figured the name 'fragment_caching' was a bit redundant for the template library since all caching within templates will be fragment caching (but maybe it's just me).

comment:4 Changed 7 years ago by John Shaffer <jshaffer2112@…>

  • Cc jshaffer2112@… added
  • Needs tests unset

comment:5 Changed 7 years ago by Fredrik Lundh <fredrik@…>

  • Keywords sprintsept14 added
  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 7 years ago by PhiR

  • Keywords feature added

comment:7 Changed 7 years ago by mtredinnick

  • Version set to SVN

comment:8 Changed 7 years ago by mtredinnick

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

(In [6580]) Fixed #1065 -- Added a "cache" template tag. Thanks, Ian Maurer and, particularly, Nick Lane.

comment:9 Changed 7 years ago by anonymous

Unusable, seem to give Unicode errors as soon as you have to do with real non-ascii characters. Was this thoroughly tested?

comment:10 Changed 7 years ago by mtredinnick

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Triage Stage changed from Ready for checkin to Accepted

Can you please give an example of how to make it fail?

comment:11 Changed 7 years ago by anonymous

Hum... for the moment it seems the problem is magically gone. But I swear nothing worked after adding it and it gave Unicode errors :/

comment:12 Changed 7 years ago by mtredinnick

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

Well, if/when you can repeat the problem, please reopen the ticket (don't just add a comment), with details. A small example, plus details of what cache you are using will be required so that we can repeat the problem.

Changed 6 years ago by zz

Improved tag to accept time as variable

comment:13 Changed 6 years ago by zz <zodizz@…>

  • Resolution fixed deleted
  • Status changed from closed to reopened

Somehow the idea of having cache time spread all over the place seems a bit cluttering especially if you use the tag more frequently throughout templates. Having the timeout in a single variable is helpful.

The patch allows the timeout to be a template variable and also adds some extra tests.

comment:14 Changed 6 years ago by SmileyChris

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

ZZ, this is new functionality, so belongs in a new ticket. Please open a new ticket for this new functionality and attach your patch to that :)

comment:15 Changed 6 years ago by zz <zodizz@…>

ok Ticket #6201

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.