From 9aeae36585f4e398ec6bb19d113d4f447630b631 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Wed, 24 Jul 2013 11:07:01 +0200 Subject: [PATCH] [entropy.server] add _cache_prefix() _cache_prefix() will be used for computing a fixed and function dependent cache key prefix that contains the module name, class name and method name (retrieved via const_get_caller()). --- lib/entropy/server/interfaces/main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/entropy/server/interfaces/main.py b/lib/entropy/server/interfaces/main.py index b3ef05960..aa6b3ec45 100644 --- a/lib/entropy/server/interfaces/main.py +++ b/lib/entropy/server/interfaces/main.py @@ -27,7 +27,7 @@ from entropy.const import etpConst, etpSys, const_setup_perms, \ const_create_working_dirs, const_convert_to_unicode, \ const_setup_file, const_get_stringtype, const_debug_write, \ const_debug_enabled, const_convert_to_rawstring, const_mkdtemp, \ - const_mkstemp + const_mkstemp, const_get_caller from entropy.output import purple, red, darkgreen, \ bold, brown, blue, darkred, teal from entropy.cache import EntropyCacher @@ -1851,6 +1851,20 @@ class Server(Client): """ return self.__instance_destroyed + def _cache_prefix(self, caller=None): + """ + Generate a cache object key prefix to use with EntropyCacher. + + @keyword caller: a custom function caller name + @type caller: string + @return: the cache prefix + @rtype: string + """ + if caller is None: + caller = const_get_caller() + return "%s/%s/%s" % ( + __name__, self.__class__.__name__, caller) + def _get_branch_from_download_relative_uri(self, db_download_uri): return db_download_uri.split("/")[2]