# ``Table`` class docstring for more information.\r
self.base_columns = copy.deepcopy(type(self).base_columns)\r
\r
+ def _reset_snapshot(self, reason):\r
+ """Called to reset the current snaptshot, for example when\r
+ options change that could affect it.\r
+\r
+ ``reason`` is given so that subclasses can decide that a\r
+ given change may not affect their snaptshot.\r
+ """\r
+ self._snapshot = None\r
+\r
def _build_snapshot(self):\r
"""Rebuild the table for the current set of options.\r
\r
\r
Subclasses should override this.\r
"""\r
- self._snapshot = copy.copy(self._data)\r
+ return self._data\r
\r
def _get_data(self):\r
if self._snapshot is None:\r
- self._build_snapshot()\r
+ self._snapshot = self._build_snapshot()\r
return self._snapshot\r
data = property(lambda s: s._get_data())\r
\r
return True\r
\r
def _set_order_by(self, value):\r
- if self._snapshot is not None:\r
- self._snapshot = None\r
+ self._reset_snapshot('order_by')\r
# accept both string and tuple instructions\r
order_by = (isinstance(value, basestring) \\r
and [value.split(',')] \\r
if self.order_by:
actual_order_by = self._resolve_sort_directions(self.order_by)
sort_table(snapshot, self._cols_to_fields(actual_order_by))
- self._snapshot = snapshot
+ return snapshot
class Table(MemoryTable):