def _cannotDetermineSort(self, defaultSortColumn): """ In this old, index-based way of doing things, we can do even more implicit horrible stuff to determine the sort column, or even give up completely and accept an implicit sort. NB: this is still terrible behavior, but lots of old code relied on it, and since this class is legacy anyway it won't be deprecated or removed. We can also accept a sort column in this table that is not actually displayed or sent to the client at all. """ if defaultSortColumn is not None: self.currentSortColumn = IColumn(defaultSortColumn)
def getInitialArguments(self): """ Return the constructor arguments required for the JavaScript client class, Mantissa.ScrollTable.ScrollTable. @return: a 3-tuple of:: - The unicode attribute ID of my current sort column - A list of dictionaries with 'name' and 'type' keys which are strings describing the name and type of all the columns in this table. - A bool indicating whether the sort direction is initially ascending. """ ic = IColumn(self.currentSortColumn) return [ ic.attributeID.decode('ascii'), self._getColumnList(), self.isAscending ]
def __init__(self, webTranslator, columns, defaultSortColumn, defaultSortAscending): self.webTranslator = webTranslator self.columns = {} self.columnNames = [] for col in columns: # see comment in TimestampAttributeColumn if isinstance(col, timestamp): col = TimestampAttributeColumn(col) else: col = IColumn(col) if defaultSortColumn is None: defaultSortColumn = col.sortAttribute() if (defaultSortColumn is not None and col.sortAttribute() is defaultSortColumn): self.currentSortColumn = col attributeID = unicode(col.attributeID, 'ascii') self.columns[attributeID] = col self.columnNames.append(attributeID) self.isAscending = defaultSortAscending if self.currentSortColumn is None: self._cannotDetermineSort(defaultSortColumn)