def view(self, category_id, categroy_page): db = Session() c.alive = alive() result = db.execute( 'select count(*) from LUM_Discussion where CategoryID=%s', category_id) c.topics_total = result.fetchone()[0] c.topics_start, c.topics_end, c.pages_current, c.pages_total = page_range( int(categroy_page), c.topics_total) log.debug('topics_total:%s start:%s end:%s', c.topics_total, c.topics_start, c.topics_end) position = c.topics_start - 1 length = c.topics_end - position #category title result = db.execute('select * from LUM_Category where CategoryID=%s', int(category_id)) c.category = result.fetchone() #topics #result = db.execute('select * from LUM_Discussion order by DiscussionID desc') result = db.execute( 'select d.DiscussionID,d.Name,c.Name,u1.Name,u2.Name,d.CountComments,d.DateLastActive from LUM_Discussion AS d Left Join (LUM_User AS u1) on (d.AuthUserID=u1.UserID) Left Join (LUM_User AS u2) on (d.LastUserID=u2.UserID),LUM_Category AS c where d.CategoryID=c.CategoryID and d.CategoryID=%s order by d.DateLastActive desc LIMIT %s,%s', (int(category_id), position, length)) c.topics = result.fetchall() return render('genshi', 'category')
def index(self,page): # Return a rendered template # return render('/some/template.mako') # or, Return a response db = Session() c.alive = alive() result = db.execute('select count(*) from LUM_Discussion') c.topics_total = result.fetchone()[0] c.topics_start, c.topics_end, c.pages_current, c.pages_total = page_range(int(page), c.topics_total) log.debug('input_page:%s topics_total:%s start:%s end:%s pages_current:%s , pages_total:%s',page,c.topics_total,c.topics_start, c.topics_end, c.pages_current, c.pages_total) position = c.topics_start - 1 length = c.topics_end - position result = db.execute('select d.DiscussionID,d.Name,c.Name,u1.Name,u2.Name,d.CountComments,d.DateLastActive from LUM_Discussion AS d Left Join (LUM_User AS u1) on (d.AuthUserID=u1.UserID) Left Join (LUM_User AS u2) on (d.LastUserID=u2.UserID),LUM_Category AS c where d.CategoryID=c.CategoryID order by d.DateLastActive desc LIMIT %s,%s',(position,length)) c.topics = result.fetchall() return render('genshi','topics')
def view(self,category_id, categroy_page): db = Session() c.alive = alive() result = db.execute('select count(*) from LUM_Discussion where CategoryID=%s', category_id) c.topics_total = result.fetchone()[0] c.topics_start, c.topics_end, c.pages_current, c.pages_total = page_range(int(categroy_page), c.topics_total) log.debug('topics_total:%s start:%s end:%s',c.topics_total,c.topics_start, c.topics_end) position = c.topics_start - 1 length = c.topics_end - position #category title result = db.execute('select * from LUM_Category where CategoryID=%s',int(category_id)) c.category = result.fetchone() #topics #result = db.execute('select * from LUM_Discussion order by DiscussionID desc') result = db.execute('select d.DiscussionID,d.Name,c.Name,u1.Name,u2.Name,d.CountComments,d.DateLastActive from LUM_Discussion AS d Left Join (LUM_User AS u1) on (d.AuthUserID=u1.UserID) Left Join (LUM_User AS u2) on (d.LastUserID=u2.UserID),LUM_Category AS c where d.CategoryID=c.CategoryID and d.CategoryID=%s order by d.DateLastActive desc LIMIT %s,%s',(int(category_id),position,length)) c.topics = result.fetchall() return render('genshi','category')