equal
deleted
inserted
replaced
1660 """ |
1660 """ |
1661 |
1661 |
1662 def __init__(self, *paths): |
1662 def __init__(self, *paths): |
1663 self.paths = paths |
1663 self.paths = paths |
1664 |
1664 |
|
1665 def tracked_paths(self, obj): |
|
1666 return [self.join(obj, path) for path in self.paths] |
|
1667 |
1665 def join(self, obj, fname): |
1668 def join(self, obj, fname): |
1666 """Used to compute the runtime path of a cached file. |
1669 """Used to compute the runtime path of a cached file. |
1667 |
1670 |
1668 Users should subclass filecache and provide their own version of this |
1671 Users should subclass filecache and provide their own version of this |
1669 function to call the appropriate join function on 'obj' (an instance |
1672 function to call the appropriate join function on 'obj' (an instance |
1688 |
1691 |
1689 if entry: |
1692 if entry: |
1690 if entry.changed(): |
1693 if entry.changed(): |
1691 entry.obj = self.func(obj) |
1694 entry.obj = self.func(obj) |
1692 else: |
1695 else: |
1693 paths = [self.join(obj, path) for path in self.paths] |
1696 paths = self.tracked_paths(obj) |
1694 |
1697 |
1695 # We stat -before- creating the object so our cache doesn't lie if |
1698 # We stat -before- creating the object so our cache doesn't lie if |
1696 # a writer modified between the time we read and stat |
1699 # a writer modified between the time we read and stat |
1697 entry = filecacheentry(paths, True) |
1700 entry = filecacheentry(paths, True) |
1698 entry.obj = self.func(obj) |
1701 entry.obj = self.func(obj) |
1707 |
1710 |
1708 def set(self, obj, value): |
1711 def set(self, obj, value): |
1709 if self.name not in obj._filecache: |
1712 if self.name not in obj._filecache: |
1710 # we add an entry for the missing value because X in __dict__ |
1713 # we add an entry for the missing value because X in __dict__ |
1711 # implies X in _filecache |
1714 # implies X in _filecache |
1712 paths = [self.join(obj, path) for path in self.paths] |
1715 paths = self.tracked_paths(obj) |
1713 ce = filecacheentry(paths, False) |
1716 ce = filecacheentry(paths, False) |
1714 obj._filecache[self.name] = ce |
1717 obj._filecache[self.name] = ce |
1715 else: |
1718 else: |
1716 ce = obj._filecache[self.name] |
1719 ce = obj._filecache[self.name] |
1717 |
1720 |