[ckan-dev] template variables

Toby Dacre toby.okfn at gmail.com
Thu Jul 26 10:24:57 UTC 2012


On 26 July 2012 10:48, David Read <david.read at hackneyworkshop.com> wrote:

> I've noticed people passing variables to CKAN templates using the
> 'extra_vars', whereas we always used to use the context (e.g. c.pkg).
> The extra_vars seems more functional and suits the render_snippet
> functionality, but is there any other reason for the change?
>
>
the render snippet uses the extra_vars to make the snippets portable

other than that I think it's ended up being a personal choice we should be
more consistent
generally as said on irc where possible we want stuff to move to helpers to
give us more flexability


> The reason I ask is that if you use extra_vars then caching is
> switched off for that page (lib/base.py). Hence all the dataset pages
> don't cache because the social plugin does render_snippet. I'm
> obviously missing something in this design - can someone explain?
>
>
the caching is a little flakey mainly because we only try to cache if
things are `safe` if we have extra_vars then they might contain user
specific stuff.  I will look at cleaning this up a bit if I get some time
but the new templates etc are the priority

there is an option to force page caching which might be what you want
render(..., force_cache=True)

Toby

> Dave
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120726/81701765/attachment-0001.html>


More information about the ckan-dev mailing list