[ckan-dev] Cache variable within a request (PackageController)

Nevelina Aleksandrova nevelina.aleksandrova at gmail.com
Mon Aug 6 15:54:44 UTC 2018


Hello CKAN team,

We have implemented an interface for IPackageController which includes
custom actions on some hooks. We were wondering if there was a way to set a
custom variable on that controller that will then be available to the
relevant views. We are looking to cache a variable in the context of the
request to reduce the number of times we need to call an external API.

We do not override the actual controller itself, so we don't have a custom
render method which would allow us to set extra_vars. According to
http://docs.ckan.org/en/ckan-2.7.0/theming/variables-and-functions.html#tmpl_context
using c to set the var in the context is evil.

Currently we're using helper functions, but we can't see how to cache state
within a request.

Any help would be very welcome!

Best,
Nevelina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20180806/8917e8b5/attachment.html>


More information about the ckan-dev mailing list