Commit f0f4311b authored by Antoine Millet's avatar Antoine Millet

Fixed persistency bug with cache and con & ip tags.

parent 057c7b65
......@@ -94,7 +94,7 @@ class CCServer(object):
for login in to_register:
conf = self.conf.show(login)
obj = TqlObject(id=login, r=conf['role'], a=login)
self.objects.register(obj, cleanable=('ip', 'con'))
self.objects.register(obj)
for login in to_unregister:
self.objects.unregister(login)
......
......@@ -267,7 +267,11 @@ class ObjectsDB(object):
else:
# The client is connected:
if parent is None:
obj.update(client.get_tags())
serv_tags = client.get_tags()
obj.update(serv_tags)
# Add an infinite ttl to server defined tags:
for tag in serv_tags:
self._ttls[(obj['id'], tag)] = datetime.max
# First, check if each tag is not already cached:
now = datetime.now()
......@@ -314,15 +318,13 @@ class ObjectsDB(object):
'''
return self._objects[oid]
def register(self, obj, cleanable=()):
def register(self, obj):
'''
Populate the database with the specified object. All the tags specified
in the passed object are not declared in cache and will never be
cleaned.
:param obj: the object to register
:param clenable: the optionnal list of tags to declare as cleanable when
the cache is cleaned
'''
with self._lock:
......@@ -332,8 +334,6 @@ class ObjectsDB(object):
raise AlreadyRegistered('The object is already registered')
else:
self._objects[obj['id']] = obj
for tag in cleanable:
self._ttls[(obj['id'], tag)] = datetime.max
def unregister(self, obj_id):
'''
......
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