本文整理汇总了Python中torlite.model.mpost.MPost.query_by_spec方法的典型用法代码示例。如果您正苦于以下问题:Python MPost.query_by_spec方法的具体用法?Python MPost.query_by_spec怎么用?Python MPost.query_by_spec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torlite.model.mpost.MPost
的用法示例。
在下文中一共展示了MPost.query_by_spec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SpecHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import query_by_spec [as 别名]
class SpecHandler(BaseHandler):
def initialize(self):
self.muser = MUser()
self.mpage = MPage()
self.mdb = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mspec = SpesubModel()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get(self, input=''):
if len(input) > 0:
ip_arr = input.split(r'/')
if input == '':
self.index()
elif input == 'add':
self.to_add()
elif len(ip_arr) == 1:
self.list(input)
elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
self.to_edit(ip_arr[0])
else:
self.render('/html/404.html')
def post(self, input=''):
if len(input) > 0:
ip_arr = input.split(r'/')
if input == '':
pass
elif input == 'add':
self.add()
elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
self.edit(ip_arr[0])
else:
self.render('/html/404.html')
self.redirect('/spec/')
@tornado.web.authenticated
def edit(self, uid):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
self.mspec.update(uid, post_data)
@tornado.web.authenticated
def add(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
self.mspec.addata(post_data)
@tornado.web.authenticated
def to_edit(self, uid):
spec_rec = self.mspec.get_by_id(uid)
self.render('tplite/spec/edit.html', spec_rec=spec_rec)
@tornado.web.authenticated
def to_add(self):
print('to_add')
self.render('tplite/spec/add.html')
def list(self, spec_slug):
'''
列出专题信息,按某一分类
'''
page_rec = self.mspec.get_by_slug(spec_slug)
kwd = {
'editable': self.editable()
}
self.render('tplite/spec/list.html',
kwd=kwd,
spec=page_rec,
unescape=tornado.escape.xhtml_unescape,
spec_recs=self.mdb.query_by_spec(page_rec.uid),
)
def index(self):
kwd = {
'editable': self.editable()
}
spec_recs = self.mspec.get_all()
self.render('tplite/spec/index.html', spec_recs=spec_recs, kwd=kwd)
示例2: SpecialHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import query_by_spec [as 别名]
class SpecialHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.mpage = MPage()
self.mpost = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mspec = SpesubModel()
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=""):
url_arr = self.parse_url(url_str)
if url_str == '':
self.index()
elif url_str == 'add':
self.to_add()
elif len(url_arr) == 1:
self.list(url_str)
elif len(url_arr) == 2 and url_arr[1] == 'edit':
self.to_edit(url_arr[0])
elif url_arr[0] == 'delete':
self.delete(url_arr[1])
else:
self.render('html/404.html')
def post(self, url_str=''):
url_arr = self.parse_url(url_str)
if url_str == 'add':
self.add()
elif len(url_arr) == 2 and url_arr[1] == 'edit':
self.edit(url_arr[0])
else:
self.render('html/404.html')
# self.redirect('/spec/')
@tornado.web.authenticated
def edit(self, uid):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
if 'slug' in post_data:
pass
else:
self.set_status(400)
return False
self.mspec.update(uid, post_data)
@tornado.web.authenticated
def add(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
if self.mspec.get_by_slug(post_data['slug'][0]) is None:
self.mspec.addata(post_data)
else:
self.set_status(400)
return False
@tornado.web.authenticated
def to_edit(self, uid):
spec_rec = self.mspec.get_by_id(uid)
self.render('{0}/spec/edit.html'.format(self.tmpl_name), spec_rec=spec_rec,
cfg = config.cfg,
)
@tornado.web.authenticated
def to_add(self):
self.render('{0}/spec/add.html'.format(self.tmpl_name))
def list(self, spec_slug):
'''
列出专题信息,按某一分类
'''
page_rec = self.mspec.get_by_slug(spec_slug)
kwd = {
'editable': self.editable()
}
self.render('{0}/spec/list.html'.format(self.tmpl_name),
kwd=kwd,
spec=page_rec,
unescape=tornado.escape.xhtml_unescape,
spec_recs=self.mpost.query_by_spec(page_rec.uid),
cfg = config.cfg,
)
def index(self):
kwd = {
'editable': self.editable()
}
self.render('{0}/spec/index.html'.format(self.tmpl_name),
#.........这里部分代码省略.........
示例3: SpecHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import query_by_spec [as 别名]
class SpecHandler(BaseHandler):
def initialize(self):
self.mpage = MPage()
self.mdb = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mspec = SpesubModel()
def get(self, input=''):
if len(input) > 0:
ip_arr = input.split(r'/')
if input == '':
self.index()
elif input == 'add':
self.to_add()
elif len(ip_arr) == 1:
self.list(input)
elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
self.to_edit(ip_arr[0])
else:
self.render('/html/404.html')
def post(self, input=''):
if len(input) > 0:
ip_arr = input.split(r'/')
if input == '':
pass
elif input == 'add':
self.add()
elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
self.edit(ip_arr[0])
else:
self.render('/html/404.html')
self.redirect('/spec/')
@tornado.web.authenticated
def edit(self, uid):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
self.mspec.update(uid, post_data)
@tornado.web.authenticated
def add(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
self.mspec.addata(post_data)
@tornado.web.authenticated
def to_edit(self, uid):
spec_rec = self.mspec.get_by_id(uid)
self.render('tplite/spec/edit.html', spec_rec=spec_rec)
@tornado.web.authenticated
def to_add(self):
# spec_rec = self.mspec.get_by_id(uid)
uuu = self.mcat.query_all()
self.render('tplite/spec/add.html', cat_recs=uuu)
def list(self, spec_slug):
'''
列出专题信息,按某一分类
'''
page_rec = self.mspec.get_by_slug(spec_slug)
# content = self.mpage.get_by_wiki(page_rec.name)
# if content is None:
# re_url = '/page/{0}'.format(tornado.escape.url_escape(page_rec.name))
# self.redirect(re_url)
recs = self.mdb.query_by_spec(page_rec.id)
kwd = {
# 'spec': content,
# 'view': recs,
'editable': self.editable()
}
self.render('tplite/spec/list.html',
kwd=kwd,
spec=page_rec,
unescape=tornado.escape.xhtml_unescape,
spec_recs=recs)
def index(self):
kwd = {
# 'spec': content,
# 'view': recs,
'editable': self.editable()
}
spec_recs = self.mspec.get_all()
self.render('tplite/spec/index.html', spec_recs=spec_recs, kwd=kwd)