def get_notes(sort_by='priority', fmt=None): notes = [] indices = rds.lrange('notes', 0, -1) app.logger.debug("found %d note IDs in index" % len(indices)) for index in indices: notes.append(Note(**rds.hgetall(index))) notes = Note.sort(notes, sort_by=sort_by) if fmt == 'json': notes = { 'notes': Note.dict_repr(notes) } return notes