client-barcode: Add an item cache

This commit is contained in:
Sebastian Pipping 2011-10-05 12:39:22 +02:00
parent 5b42351454
commit 61af03c5f9
1 changed files with 7 additions and 1 deletions

View File

@ -56,6 +56,7 @@ def error_page(message):
class Status:
def __init__(self):
self._reset()
self.item_cache = dict()
def _reset(self):
self.auth_blob = None
@ -122,7 +123,12 @@ class Status:
self._reset()
def find(self, item_id):
return net.get_item(item_id)
try:
return self.item_cache[item_id]
except KeyError:
item = net.get_item(item_id)
self.item_cache[item_id] = item
return item
def buy(self, item):
assert(self.logged_in())