2013-02-24 19:58:02 +08:00
|
|
|
import hashlib
|
2017-01-26 21:25:15 +08:00
|
|
|
from urllib.parse import quote
|
2015-01-28 20:35:27 +08:00
|
|
|
|
2013-02-24 19:58:02 +08:00
|
|
|
TEMPLATE_FRAGMENT_KEY_TEMPLATE = 'template.cache.%s.%s'
|
|
|
|
|
|
|
|
|
|
|
|
def make_template_fragment_key(fragment_name, vary_on=None):
|
|
|
|
if vary_on is None:
|
|
|
|
vary_on = ()
|
2017-01-26 21:25:15 +08:00
|
|
|
key = ':'.join(quote(str(var)) for var in vary_on)
|
2018-02-02 15:57:58 +08:00
|
|
|
args = hashlib.md5(key.encode())
|
2013-02-24 19:58:02 +08:00
|
|
|
return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
|