本文整理汇总了Python中torlite.model.muser.MUser类的典型用法代码示例。如果您正苦于以下问题:Python MUser类的具体用法?Python MUser怎么用?Python MUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AdminHandler
class AdminHandler(tornado.web.RequestHandler):
def initialize(self):
self.mpost = MPost()
self.mcat = MCatalog()
self.muser = MUser()
self.mpage = MPage()
self.mlink = MLink()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get_current_user(self):
return self.get_secure_cookie("user")
def get(self, input=''):
if input == '':
self.index()
else:
self.render('html/404.html')
@tornado.web.authenticated
def index(self):
self.render('admin/admin_index.html',
user_info=self.muser.get_by_id(self.get_current_user())
)
示例2: SimpleWidgetTestCase
class SimpleWidgetTestCase(unittest.TestCase):
def setUp(self):
self.muser = MUser()
payload1 = {
'user_name': 'giser1',
'user_pass': '1234567',
}
self.r1 = requests.post('http://127.0.0.1:8088/user/regist', payload1)
payload1 = {
'user_name': 'giser1',
'user_pass': '1234567',
'user_email': 'sadf',
}
self.r2 = requests.post('http://127.0.0.1:8088/user/regist', payload1)
payload3 = {
'user_name': 'giser1',
'user_pass': '1234567',
'user_email': '[email protected]',
}
self.r3 = requests.post('http://127.0.0.1:8088/user/regist', payload3)
# 相同用户名注册
self.r55 = requests.post('http://127.0.0.1:8088/user/regist', payload3)
self.r4 = requests.post('http://127.0.0.1:8088/user/login', payload3)
payload4 = {
'user_name': 'giser1',
'user_pass': '7654321',
}
self.r5 = requests.post('http://127.0.0.1:8088/user/login', payload4)
def tearDown(self):
self.muser.delete_by_user_name('giser1')
示例3: LabelHandler
class LabelHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.mequa = MPost()
self.mtag = MLabel()
self.mapp2tag = MPost2Label()
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 len(url_arr) == 1:
self.list(url_str)
elif len(url_arr) == 2:
self.list(url_arr[0], url_arr[1])
else:
return False
# def post(self, url_str=''):
# if len(url_str) > 0:
# url_arr = url_str.split('/')
# else:
# return False
#
# if url_arr[0] == 'edit':
# self.edit(url_arr[1])
def list(self, tag_slug, cur_p=''):
'''
根据 cat_handler.py 中的 def view_cat_new(self, cat_slug, cur_p = '')
:param tag_slug:
:return:
'''
if cur_p == '':
current_page_number = 1
else:
current_page_number = int(cur_p)
current_page_number = 1 if current_page_number < 1 else current_page_number
pager_num = int(self.mapp2tag.total_number(tag_slug) / config.page_num)
tag_name = ''
kwd = {
'tag_name': tag_name,
'tag_slug': tag_slug,
'title': tag_name,
}
self.render('{0}/label/list.html'.format(self.tmpl_name),
infos=self.mapp2tag.query_pager_by_slug(tag_slug, current_page_number),
unescape=tornado.escape.xhtml_unescape,
kwd=kwd,
userinfo=self.userinfo,
pager=tools.gen_pager_bootstrap_url('/label/{0}'.format(tag_slug), pager_num, current_page_number),
cfg = config.cfg,
)
示例4: initialize
def initialize(self):
self.mjson = MJson()
self.muser = MUser()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
示例5: AppIndexHandler
class AppIndexHandler(BaseHandler):
def initialize(self):
self.mpost = MPost()
self.mcat = MCatalog()
self.muser = MUser()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
self.tmpl_sig = app_template_name
def get(self, input=''):
if input == '':
self.index()
else:
self.render('html/404.html')
def index(self):
cstr = tools.get_uuid()
self.set_cookie('user_pass', cstr)
kwd = {
'cookie_str': cstr
}
self.render('{0}/index/index.html'.format(self.tmpl_sig),
kwd=kwd,
userinfo=self.userinfo,
catalog_info=self.mcat.query_all(by_order=True)
)
示例6: initialize
def initialize(self):
self.mapplication = MApp()
self.muser = MUser()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
示例7: setUp
def setUp(self):
self.muser = MUser()
payload1 = {
'user_name': 'giser1',
'user_pass': '1234567',
}
self.r1 = requests.post('http://127.0.0.1:8088/user/regist', payload1)
payload1 = {
'user_name': 'giser1',
'user_pass': '1234567',
'user_email': 'sadf',
}
self.r2 = requests.post('http://127.0.0.1:8088/user/regist', payload1)
payload3 = {
'user_name': 'giser1',
'user_pass': '1234567',
'user_email': '[email protected]',
}
self.r3 = requests.post('http://127.0.0.1:8088/user/regist', payload3)
# 相同用户名注册
self.r55 = requests.post('http://127.0.0.1:8088/user/regist', payload3)
self.r4 = requests.post('http://127.0.0.1:8088/user/login', payload3)
payload4 = {
'user_name': 'giser1',
'user_pass': '7654321',
}
self.r5 = requests.post('http://127.0.0.1:8088/user/login', payload4)
示例8: IndexHandler
class IndexHandler(BaseHandler):
def initialize(self):
self.mpost = MPost()
self.mcat = MCatalog()
self.muser = MUser()
self.mpage = MPage()
self.mlink = MLink()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get_current_user(self):
return self.get_secure_cookie("user")
def get(self, input=''):
if input == '':
self.index()
else:
self.render('html/404.html')
def index(self):
cstr = tools.get_uuid()
self.set_cookie('user_pass', cstr)
kwd = {
'cookie_str': cstr
}
self.render('index/index.html',
userinfo=self.userinfo,
catalog_info=self.mcat.query_all(by_order=True),
link= self.mlink.query_all(),
unescape=tornado.escape.xhtml_unescape,
cfg = config.cfg,
kwd=kwd,)
示例9: PycateBaseHandler
class PycateBaseHandler(tornado.web.RequestHandler):
def init_condition(self):
self.muser = MUser()
userid = self.get_secure_cookie('user')
if userid is None:
self.user_name = ''
else:
self.user_name = userid.decode('utf-8')
self.city_name = 'changchun'
self.minfo = MInfo(self.city_name)
self.mcity = MCity()
# self.muser_info = MUserInfo(self.user_name)
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get_current_user(self):
return self.get_secure_cookie("user")
示例10: IndexHandler
class IndexHandler(tornado.web.RequestHandler):
def initialize(self):
self.mpost = MPost()
self.mcat = MCatalog()
self.muser = MUser()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def get_current_user(self):
return self.get_secure_cookie("user")
def get(self, input=''):
if input == '':
self.index()
else:
self.render('html/404.html')
def index(self):
cstr = tools.get_uuid()
self.set_cookie('user_pass', cstr)
kwd = {
'cookie_str': cstr
}
self.render('tplite/index/index.html',
kwd = kwd,
userinfo=self.userinfo,
catalog_info = self.mcat.query_all( by_order=True)
)
示例11: ReplyHandler
class ReplyHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.mreply = MReply()
self.mreply2user = MReply2User()
self.mpost2reply = MPost2Reply()
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_arr[0] == 'get':
self.get_by_id(url_arr[1])
def get_by_id(self, reply_id):
reply = self.mreply.get_reply_by_uid(reply_id)
self.render('{0}/reply/show_reply.html'.format(self.tmpl_name),
cnt=reply.cnt_html,
username=reply.user_name,
date=reply.date,
vote=reply.vote,
uid=reply.uid,
userinfo=self.userinfo,
unescape=tornado.escape.xhtml_unescape,
)
示例12: init
def init(self):
self.tmpl_name= config.torlite_template_name
self.muser = MUser()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
示例13: BaseHandler
class BaseHandler(tornado.web.RequestHandler, TemplateRendring):
def init(self):
self.tmpl_name= config.torlite_template_name
self.muser = MUser()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
def parse_url(self, url_str):
url_str = url_str.strip()
url_arr = [] if len(url_str) == 0 else url_str.split('/')
return url_arr
def get_current_user(self):
return self.get_secure_cookie("user")
def editable(self):
# Deprecated.
if self.get_current_user():
return 1
else:
return 0
def render_jinja2(self, template_name, **kwargs):
kwargs.update({
'settings': self.settings,
'STATIC_URL': self.settings.get('static_url_prefix', '/static/'),
'request': self.request,
'current_user': self.current_user,
'xsrf_token': self.xsrf_token,
'xsrf_form_html': self.xsrf_form_html,
})
content = self.render_template(template_name, **kwargs)
self.write(content)
示例14: initialize
def initialize(self):
self.init()
self.muser = MUser()
self.mlink = MLink()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None
示例15: initialize
def initialize(self):
self.mequa = MApp()
self.musage = MUsage()
self.muser = MUser()
if self.get_current_user():
self.userinfo = self.muser.get_by_id(self.get_current_user())
else:
self.userinfo = None