def getUserbyUsername(self, uname): mu = MUser.query.filter_by(username=uname).first() if mu is None: return None u = User(mu.username, mu.name) u._id = mu.id return u
def getUserbyID(self, uid): mu = MUser.query.get(uid) if mu is None: return None u = User(mu.username, mu.name, self._castNumberToPermission(mu.security_flags)) u._id = mu.id return u
def getAllUsers(self, start=0, end=None): """ Get all posts by IDorder, from start to start+end. If none found, return empty list """ us = [] muq = MUser.query.order_by(MUser.id).offset(start) if not (end is None): muq = muq.limit(end) mu = muq.all() if mu is None: return [] for muitem in mu: u = User(muitem.username, muitem.name, self._castNumberToPermission(muitem.security_flags)) u._id = muitem.id us.append(u) return us