def addLazyItem(self, item_key, value_callable, *pargs, **kwargs):
"""Add a lazy item for the given key. When the item is requested,
value_callable will be called with *pargs and **kwargs arguments."""
+ if not pargs:
+ pargs = None
+ if not kwargs:
+ kwargs = None
self.lazy_items[item_key] = (value_callable, pargs, kwargs)
# make it show up in self.keys(), etc...
dict.__setitem__(self, item_key, None)
def __getitem__(self, item_key):
if item_key in self.lazy_items:
value_callable, pargs, kwargs = self.lazy_items[item_key]
+ if pargs is None:
+ pargs = ()
+ if kwargs is None:
+ kwargs = {}
return value_callable(*pargs, **kwargs)
else:
return dict.__getitem__(self, item_key)