+
+class Diagonal(CellConstraint):
+ def __init__(self, grid, direction='down', offset=0):
+ self._grid = ref(grid)
+ self._direction = direction
+ self._offset = offset
+
+ if direction == 'down':
+ coords = {'row': 0, 'column': 0}
+ increment = 1
+ elif direction == 'up':
+ coords = {'row': 0, 'column': grid.size - 1}
+ increment = -1
+ else:
+ raise Exception # XXX
+
+ # XXX
+ if offset != 0:
+ raise NotImplementedError
+
+ self._cells = []
+ for i in xrange(self.grid.size):
+ self._cells.append(ref(self.grid.cell(coords['row'], coords['column'])))
+ coords['row'] += 1
+ coords['column'] += increment