本文整理汇总了Python中torlite.model.mpost.MPost.update方法的典型用法代码示例。如果您正苦于以下问题:Python MPost.update方法的具体用法?Python MPost.update怎么用?Python MPost.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torlite.model.mpost.MPost
的用法示例。
在下文中一共展示了MPost.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PostHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import update [as 别名]
class PostHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.mpost = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mspec = SpesubModel()
self.specs = self.mspec.get_all()
self.mpost_hist = MPostHist()
self.mpost2catalog = MPost2Catalog()
self.mpost2reply = MPost2Reply()
self.mapp2tag = MPost2Label()
self.mrel = MRelation()
self.tmpl_router = 'post'
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get(self, url_str=''):
if url_str == '':
self.recent()
url_arr = url_str.split('/')
if len(url_arr) == 1 and url_str.endswith('.html'):
self.wiki(url_str.split('.')[0])
elif url_str == 'add_document':
self.to_add_document()
elif url_str == 'recent':
self.recent()
elif url_str == 'refresh':
self.refresh()
elif (url_arr[0] == 'modify'):
self.to_modify(url_arr[1])
elif url_arr[0] == 'delete':
self.delete(url_arr[1])
else:
kwd = {
'info': '页面未找到',
}
self.render('html/404.html', kwd=kwd)
def post(self, url_str=''):
if url_str == '':
return
url_arr = url_str.split('/')
if len(url_arr) == 1 and url_str.endswith('.html'):
self.add_post()
if url_arr[0] == 'modify':
self.update(url_arr[1])
elif url_str == 'add_document':
self.user_add_post()
elif url_arr[0] == 'add_document':
self.user_add_post()
else:
self.redirect('/html/404.html')
def recent(self, with_catalog=True, with_date=True):
kwd = {
'pager': '',
'unescape': tornado.escape.xhtml_unescape,
'title': '最近文档',
'with_catalog': with_catalog,
'with_date': with_date,
}
self.render('{0}/{1}/post_list.html'.format(self.tmpl_name, self.tmpl_router),
kwd=kwd,
view=self.mpost.query_recent(),
view_all=self.mpost.query_all(),
format_date=tools.format_date,
userinfo=self.userinfo,
)
def refresh(self):
kwd = {
'pager': '',
'title': '最近文档',
}
self.render('{0}/{1}/post_list.html'.format(self.tmpl_name, self.tmpl_router),
kwd=kwd,
userinfo=self.userinfo,
view=self.mpost.query_dated(10),
format_date=tools.format_date,
unescape=tornado.escape.xhtml_unescape, )
def get_random(self):
return self.mpost.query_random()
def wiki(self, uid):
dbdate = self.mpost.get_by_id(uid)
if dbdate:
self.mpost.update_view_count_by_uid(dbdate.uid)
self.viewit(uid)
#.........这里部分代码省略.........
示例2: PostHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import update [as 别名]
class PostHandler(BaseHandler):
def initialize(self):
self.muser = MUser()
self.mpost = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mspec = SpesubModel()
self.specs = self.mspec.get_all()
self.mpost_hist = MPostHist()
self.mpost2catalog = MPost2Catalog()
self.mpost2reply = MPost2Reply()
self.mapp2tag = MPost2Label()
self.mrel = MRelation()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get(self, url_str=""):
if url_str == "":
return
url_arr = url_str.split("/")
if len(url_arr) == 1 and url_str.endswith(".html"):
self.wiki(url_str.split(".")[0])
# 弃用, /search 代替
# elif url_arr[0] == 'find':
# self.find(url_arr[1])
# elif url_str == 'find':
# self.to_find()
elif url_str == "add_document":
self.to_add_document()
elif url_str == "recent":
self.recent()
elif url_str == "refresh":
self.refresh()
elif url_arr[0] == "modify":
self.to_modify(url_arr[1])
else:
kwd = {"info": "页面未找到"}
self.render("html/404.html", kwd=kwd)
def post(self, url_str=""):
if url_str == "":
return
url_arr = url_str.split("/")
if len(url_arr) == 1 and url_str.endswith(".html"):
sig = url_str.split(".")[0]
self.add_post()
if url_arr[0] == "modify":
self.update(url_arr[1])
elif url_str == "find":
self.post_find()
elif url_str == "add_document":
self.user_add_post()
elif url_arr[0] == "add":
self.add_post()
else:
self.redirect("/html/404.html")
def to_find(self,):
kwd = {"pager": ""}
self.render("tplite/post/find.html", topmenu="", kwd=kwd)
def recent(self):
kwd = {"pager": "", "unescape": tornado.escape.xhtml_unescape, "title": "最近文档"}
self.render(
"tplite/post/all.html".format(input),
kwd=kwd,
view=self.mpost.query_recent(),
format_date=tools.format_date,
userinfo=self.userinfo,
)
def refresh(self):
kwd = {"pager": "", "title": "最近文档"}
self.render(
"tplite/post/refresh.html",
kwd=kwd,
userinfo=self.userinfo,
view=self.mpost.query_dated(10),
format_date=tools.format_date,
unescape=tornado.escape.xhtml_unescape,
)
def post_find(self):
keyword = self.get_argument("keyword")
self.find(keyword)
def find(self, keyword):
kwd = {"pager": "", "unescape": tornado.escape.xhtml_unescape, "title": "查找结果"}
self.render("tplite/post/find_list.html".format(input), kwd=kwd, view=self.mpost.get_by_keyword(keyword))
#.........这里部分代码省略.........
示例3: PostHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import update [as 别名]
class PostHandler(BaseHandler):
def initialize(self):
self.muser = MUser()
self.mpost = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mspec = SpesubModel()
self.specs = self.mspec.get_all()
self.mpost_hist = MPostHist()
self.mpost2catalog = MPost2Catalog()
self.mreply = MReply()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get(self, url_str=''):
if url_str == '':
return
url_arr = url_str.split('/')
if len(url_arr) == 1 and url_str.endswith('.html'):
self.wiki(url_str.split('.')[0])
elif url_str == 'find':
self.to_find()
elif url_arr[0] == 'find':
self.find(url_arr[1])
elif url_str == 'recent':
self.recent()
elif url_str == 'refresh':
self.refresh()
elif (url_arr[0] == 'modify'):
self.to_modify(url_arr[1])
else:
kwd = {
'info': '页面未找到',
}
self.render('html/404.html', kwd=kwd)
def post(self, url_str=''):
if url_str == '':
return
url_arr = url_str.split('/')
if url_arr[0] == 'modify':
self.update(url_arr[1])
elif url_str == 'find':
self.post_find()
elif url_arr[0] == 'add':
self.add_post(url_arr[1])
elif url_arr[0] == 'comment_add':
self.add_comment(url_arr[1])
else:
self.redirect('html/404.html')
def to_find(self, ):
kwd = {
'pager': '',
}
self.render('tplite/post/find.html', topmenu='', kwd=kwd)
def recent(self):
kwd = {
'pager': '',
'unescape': tornado.escape.xhtml_unescape,
'title': '最近文档',
}
self.render('tplite/post/all.html'.format(input),
kwd=kwd,
view=self.mpost.query_recent(),
# rand_recs=self.get_random(),
format_date=tools.format_date, )
def refresh(self):
kwd = {
'pager': '',
'title': '最近文档',
}
self.render('tplite/post/all.html'.format(input),
kwd=kwd,
view=self.mpost.query_dated(60),
format_date=tools.format_date,
unescape=tornado.escape.xhtml_unescape, )
def post_find(self):
keyword = self.get_argument('keyword')
self.find(keyword)
def find(self, keyword):
kwd = {
'pager': '',
'unescape': tornado.escape.xhtml_unescape,
'title': '查找结果',
}
#.........这里部分代码省略.........
示例4: PostHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import update [as 别名]
class PostHandler(BaseHandler):
def initialize(self):
self.muser = MUser()
self.mpost = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mspec = SpesubModel()
self.specs = self.mspec.get_all()
self.mpost_hist = MPostHist()
self.mpost2catalog = MPost2Catalog()
self.mpost2reply = MPost2Reply()
self.mapp2tag = MPost2Label()
self.mrel = MRelation()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get(self, url_str=''):
if url_str == '':
return
url_arr = url_str.split('/')
if len(url_arr) == 1 and url_str.endswith('.html'):
self.wiki(url_str.split('.')[0])
# 弃用, /search 代替
# elif url_arr[0] == 'find':
# self.find(url_arr[1])
# elif url_str == 'find':
# self.to_find()
elif url_str == 'add_document':
self.to_add_document()
elif url_str == 'recent':
self.recent()
elif url_str == 'refresh':
self.refresh()
elif (url_arr[0] == 'modify'):
self.to_modify(url_arr[1])
else:
kwd = {
'info': '页面未找到',
}
self.render('html/404.html', kwd=kwd)
def post(self, url_str=''):
if url_str == '':
return
url_arr = url_str.split('/')
if len(url_arr) == 1 and url_str.endswith('.html'):
sig = url_str.split('.')[0]
self.add_post()
if url_arr[0] == 'modify':
self.update(url_arr[1])
elif url_str == 'find':
self.post_find()
elif url_str == 'add_document':
self.user_add_post()
elif url_arr[0] == 'add':
self.add_post()
else:
self.redirect('/html/404.html')
def to_find(self, ):
kwd = {
'pager': '',
}
self.render('tplite/post/find.html', topmenu='', kwd=kwd)
def recent(self):
kwd = {
'pager': '',
'unescape': tornado.escape.xhtml_unescape,
'title': '最近文档',
}
self.render('tplite/post/all.html'.format(input),
kwd=kwd,
view=self.mpost.query_recent(),
format_date=tools.format_date,
userinfo=self.userinfo,
)
def refresh(self):
kwd = {
'pager': '',
'title': '最近文档',
}
self.render('tplite/post/refresh.html',
kwd=kwd,
userinfo=self.userinfo,
view=self.mpost.query_dated(10),
format_date=tools.format_date,
#.........这里部分代码省略.........