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): ...@@ -212,6 +212,8 @@ def _syncComputerInformation(func):
Synchronize computer object with server information Synchronize computer object with server information
""" """
def decorated(self, *args, **kw): 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, # XXX: This is a ugly way to keep backward compatibility,
# We should stablise slap library soon. # We should stablise slap library soon.
try: try:
...@@ -224,6 +226,9 @@ def _syncComputerInformation(func): ...@@ -224,6 +226,9 @@ def _syncComputerInformation(func):
setattr(self, key, value.encode('utf-8')) setattr(self, key, value.encode('utf-8'))
else: else:
setattr(self, key, value) 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 func(self, *args, **kw)
return decorated return decorated
...@@ -320,6 +325,9 @@ def _syncComputerPartitionInformation(func): ...@@ -320,6 +325,9 @@ def _syncComputerPartitionInformation(func):
setattr(self, key, new_dict) setattr(self, key, new_dict)
else: else:
setattr(self, key, value) 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 func(self, *args, **kw)
return decorated 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