github.com/miguelgrinberg/microblog/blob/master/app/models.py # line 19
全文搜索的类变量里,传的 cls 是什么意思?不是太理解:
class SearchableMixin(object): @classmethod def search(cls, expression, page, per_page): ids, total = query_index(cls.__tablename__, expression, page, per_page) if total == 0: return cls.query.filter_by(id=0), 0 when = [] for i in range(len(ids)): when.append((ids[i], i)) return cls.query.filter(cls.id.in_(ids)).order_by( db.case(when, value=cls.id)), total ...... 