Exemple #1
0
 def get_from_userid(cls, userid):
     try:
         return cls.query.filter(
             db.and_(cls.id==userid,
                     cls.delflag==False)).one()
     except:
         return None
Exemple #2
0
 def get_from_entryid(cls, entryid):
     try:
         return cls.query.filter(db.and_(
                     cls.entry_id==entryid,
                     cls.delflag==False,
                     cls.publishflag==True)).order_by('id')
     except:
         return None
Exemple #3
0
 def get_from_commentid(cls, commentid):
     try:
         return cls.query.filter(db.and_(
                 cls.id==commentid,
                 cls.delflag==False,
                 cls.publishflag==True)).one()
     except:
         return None
Exemple #4
0
 def get_from_username(cls, username):
     try:
         loginname = username.lower()
         return cls.query.filter(
             db.and_(cls.name==username,
                     cls.delflag==False)).one()
     except:
         return None
Exemple #5
0
 def get_recently(cls, count):
     try:
         return cls.query.filter(db.and_(
                 cls.delflag==False,
                 cls.draftflag==False)).order_by('-id').limit(count)
     except:
         if count > 1:return []
         else:return None
Exemple #6
0
 def get_from_entryid(cls, entryid):
     try:
         return cls.query.filter(db.and_(
                 cls.id==entryid,
                 cls.delflag==False,
                 cls.draftflag==False)).one()
     except:
         return None
Exemple #7
0
 def get_from_username_password(cls, username, password):
     try:
         loginname = username.lower()
         loginpassword = sha256(password).hexdigest()
         return cls.query.filter(db.and_(
                 cls.name==username,
                 cls.password==loginpassword,
                 cls.delflag==False)).first()
     except :
         return None
Exemple #8
0
    def get_recently(cls, count):
        try:
            comments = cls.query.filter(db.and_(
                    cls.delflag==False,
                    cls.publishflag==True)).order_by('-id').limit(count)
            return comments

        except:
            if count > 1: return []
            else:
                return None
Exemple #9
0
 def get_for_page(cls, page, PER_PAGE):
     try:
         count = cls.count_all()
         offset = PER_PAGE * (page - 1)
         return cls.query.filter(db.and_(
                     cls.delflag==False,
                     cls.draftflag==False)).\
                                     order_by('-id').limit(PER_PAGE).offset(offset)
     except:
         if PER_PAGE > 1:return []
         else:return None
Exemple #10
0
 def get_from_id(cls, id, delflag=False):
     try:
         return cls.query.filter(db.and_(
                 cls.id==id,cls.delflag==delflag)).one()
     except:
         return None