Commit e86433b1 authored by Yingjie Xu's avatar Yingjie Xu

We should cache all information from vifib server.

This will reduce queries to server and improve performance for client.
parent 86cbc31f
......@@ -212,6 +212,8 @@ def _syncComputerInformation(func):
Synchronize computer object with server information
"""
def decorated(self, *args, **kw):
if getattr(self, '_synced', 0):
return func(self, *args, **kw)
# XXX: This is a ugly way to keep backward compatibility,
# We should stablise slap library soon.
try:
......@@ -224,6 +226,9 @@ def _syncComputerInformation(func):
setattr(self, key, value.encode('utf-8'))
else:
setattr(self, key, value)
setattr(self, '_synced', True)
for computer_partition in self.getComputerPartitionList():
setattr(computer_partition, '_synced', True)
return func(self, *args, **kw)
return decorated
......@@ -320,6 +325,9 @@ def _syncComputerPartitionInformation(func):
setattr(self, key, new_dict)
else:
setattr(self, key, value)
setattr(self, '_synced', True)
for computer_partition in self.getComputerPartitionList():
setattr(computer_partition, '_synced', True)
return func(self, *args, **kw)
return decorated
......
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