Django

Code

Ticket #1065 (closed: fixed)

Opened 3 years ago

Last modified 1 year ago

Add a template tag that allows for partial caching of templates

Reported by: deric <deric@monowerks.com> Assigned to: nobody
Milestone: Component: Template system
Version: SVN Keywords: sprintsept14 feature
Cc: jshaffer2112@gmail.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

See: http://groups.google.com/group/django-users/browse_thread/thread/5631d13a9d114083/40cd671d71762905?lnk=raot#40cd671d71762905

This is a nice idea. Just wanted to make sure this one was captured.

Attachments

fragment_caching.py (1.2 kB) - added by SmileyChris on 02/05/07 13:46:08.
Ian Maurer's template tag
fragment_caching_docs.diff (1.6 kB) - added by nick.lane.au@gmail.com on 02/16/07 09:22:27.
Added docs
fragment_caching.diff (5.7 kB) - added by nick.lane.au@gmail.com on 07/06/07 11:23:41.
Combined patches and added some tests.
fragment_caching.2.diff (5.5 kB) - added by nick.lane.au@gmail.com on 07/06/07 21:29:09.
Renamed template library to 'cache'
cache_tag.diff (4.3 kB) - added by zz on 12/12/07 15:54:55.
Improved tag to accept time as variable

Change History

02/05/07 13:45:29 changed by SmileyChris

  • needs_docs set to 1.
  • has_patch set to 1.
  • 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 %}

02/05/07 13:46:08 changed by SmileyChris

  • attachment fragment_caching.py added.

Ian Maurer's template tag

02/16/07 09:22:27 changed by nick.lane.au@gmail.com

  • attachment fragment_caching_docs.diff added.

Added docs

05/30/07 18:13:36 changed by SmileyChris

  • needs_docs deleted.
  • needs_tests set to 1.

07/06/07 11:23:41 changed by nick.lane.au@gmail.com

  • attachment fragment_caching.diff added.

Combined patches and added some tests.

07/06/07 21:29:09 changed by nick.lane.au@gmail.com

  • attachment fragment_caching.2.diff added.

Renamed template library to 'cache'

07/06/07 21:51:24 changed by nick.lane.au@gmail.com

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).

07/06/07 23:36:47 changed by John Shaffer <jshaffer2112@gmail.com>

  • cc set to jshaffer2112@gmail.com.
  • needs_tests deleted.

09/15/07 07:44:11 changed by Fredrik Lundh <fredrik@pythonware.com>

  • keywords set to sprintsept14.
  • stage changed from Accepted to Ready for checkin.

09/15/07 14:33:13 changed by PhiR

  • keywords changed from sprintsept14 to sprintsept14 feature.

10/20/07 09:01:46 changed by mtredinnick

  • version set to SVN.

10/21/07 10:48:40 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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

10/21/07 12:31:00 changed by anonymous

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

10/21/07 12:52:18 changed by mtredinnick

  • status changed from closed to reopened.
  • resolution deleted.
  • stage changed from Ready for checkin to Accepted.

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

10/21/07 16:49:53 changed 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 :/

10/21/07 16:51:06 changed by mtredinnick

  • status changed from reopened to closed.
  • resolution set to fixed.

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.

12/12/07 15:54:55 changed by zz

  • attachment cache_tag.diff added.

Improved tag to accept time as variable

12/12/07 16:20:40 changed by zz <zodizz@gmail.com>

  • status changed from closed to reopened.
  • resolution deleted.

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.

12/12/07 18:33:37 changed by SmileyChris

  • status changed from reopened to closed.
  • resolution set to fixed.

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

12/13/07 03:57:48 changed by zz <zodizz@gmail.com>

ok Ticket #6201


Add/Change #1065 (Add a template tag that allows for partial caching of templates)




Change Properties
Action