def forum_info(fid): tableObj = model.forum() ##获取数据表对象 f_info = tableObj.getOne('title, content', {'id': fid}) ##进行表查询 tableObj = model.query() ##获取数据表对象 reply = tableObj.fetchAll( 'select content,parent_content from reply where fid=%s' % fid) ##进行表查询 return f_info, reply
def index(self): users = model.user().getList('*') ##进行表查询 self.assign('users', users) ##设置为模板变量 group = model.groups().getList('*') self.assign('group', group) forum = model.forum().getList('*') self.assign('forum', forum) return self.display('index') ##显示指定模板
def forum_new(pars): condition = dict(pars) user_info = web.ctx.session.user_info if user_info: condition['owner'] = user_info['id'] else: return -1 gid = condition.pop('gid') if not gid: return -2 tableObj = model.forum() rt1 = tableObj.insert(condition) print rt1 tableObj = model.group_forum() condition = {'fid':rt1, 'gid':gid} rt2 = tableObj.insert(condition) if rt1 and rt2: return 1 else: return 0
def forum_new(pars): condition = dict(pars) user_info = web.ctx.session.user_info if user_info: condition['owner'] = user_info['id'] else: return -1 gid = condition.pop('gid') if not gid: return -2 tableObj = model.forum() rt1 = tableObj.insert(condition) print rt1 tableObj = model.group_forum() condition = {'fid': rt1, 'gid': gid} rt2 = tableObj.insert(condition) if rt1 and rt2: return 1 else: return 0
def forum_info(fid): tableObj = model.forum() ##获取数据表对象 f_info = tableObj.getOne('title, content', {'id':fid}) ##进行表查询 tableObj = model.query() ##获取数据表对象 reply = tableObj.fetchAll('select content,parent_content from reply where fid=%s' % fid) ##进行表查询 return f_info,reply