Commit e45ee9df authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Minor clean up on SlapOSCacheMixin

parent a974c377
Pipeline #19285 failed with stage
in 0 seconds
......@@ -78,6 +78,7 @@ class SlapOSCacheMixin:
}
# Prepare for xml marshalling
data_dict["text"] = data_dict["text"].decode("UTF-8")
data_dict["user"] = data_dict["user"].decode("UTF-8")
return data_dict
data_dict = json.loads(data_json)
......@@ -89,19 +90,14 @@ class SlapOSCacheMixin:
data_dict["no_data_since_5_minutes"] = 1
elif (DateTime() - last_contact) > 0.0025:
data_dict["no_data_since_5_minutes"] = 1
# Prepare for xml marshalling
data_dict["user"] = data_dict["user"].decode("UTF-8")
data_dict["text"] = data_dict["text"].decode("UTF-8")
return data_dict
def setAccessStatus(self, text, state=""):
user_reference = self.getPortalObject().portal_membership.getAuthenticatedMember()\
.getUserName()
memcached_dict = self._getSlapOSMemcacheDict()
memcached_dict = self._getSlapOSMemcacheDict()
previous = self._getCachedAccessInfo()
created_at = rfc1123_date(DateTime())
since = created_at
......@@ -128,25 +124,23 @@ class SlapOSCacheMixin:
#####################
# SlapOS Last Data
#####################
def _getLastDataPlugin(self):
def _getLastDataCacheFactory(self):
return self.getPortalObject().portal_caches\
.getRamCacheRoot().get('last_stored_data_cache_factory')\
.getCachePluginList()[0]
.getRamCacheRoot().get('last_stored_data_cache_factory')
def _getLastDataPlugin(self):
return self._getLastDataCacheFactory().getCachePluginList()[0]
def setLastData(self, value, key=None):
# Key is used as suffix of reference, so
# each instance cannot modify others informations.
cache_key = self.getReference()
if key is not None:
cache_key += key
self._getLastDataPlugin().set(cache_key, DEFAULT_CACHE_SCOPE, value,
cache_duration=self.getPortalObject().portal_caches\
.getRamCacheRoot().get('last_stored_data_cache_factory').cache_duration)
cache_key = key
cache_duration = self._getLastDataCacheFactory().cache_duration
self._getLastDataPlugin().set(cache_key, DEFAULT_CACHE_SCOPE,
value, cache_duration=cache_duration)
def getLastData(self, key=None):
# Key is used as suffix of reference, so
# each instance cannot modify others informations.
cache_key = self.getReference()
if key is not None:
cache_key = key
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment