当前位置: 首页>>代码示例>>Python>>正文


Python MUser.get_by_id方法代码示例

本文整理汇总了Python中torlite.model.muser.MUser.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python MUser.get_by_id方法的具体用法?Python MUser.get_by_id怎么用?Python MUser.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torlite.model.muser.MUser的用法示例。


在下文中一共展示了MUser.get_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AdminHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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())
                    )
开发者ID:southwestjiaotongunivercity,项目名称:TorCMS,代码行数:28,代码来源:admin_handler.py

示例2: LabelHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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,
                    )
开发者ID:vaveee,项目名称:TorCMS,代码行数:62,代码来源:label_handler.py

示例3: PycateBaseHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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")
开发者ID:jiaxiaolei,项目名称:pycate,代码行数:31,代码来源:base_handler.py

示例4: AppIndexHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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)
                    )
开发者ID:shiweihappy,项目名称:maplet,代码行数:30,代码来源:index_app.py

示例5: IndexHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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)
                    )
开发者ID:Ryan007,项目名称:TorCMS,代码行数:32,代码来源:index.py

示例6: IndexHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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,)
开发者ID:vaveee,项目名称:TorCMS,代码行数:36,代码来源:index.py

示例7: ReplyHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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,
                    )
开发者ID:vaveee,项目名称:TorCMS,代码行数:32,代码来源:reply_handler.py

示例8: BaseHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
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)
开发者ID:hitrustnet,项目名称:TorCMS,代码行数:37,代码来源:base_handler.py

示例9: MaintainCategoryAjaxHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
class MaintainCategoryAjaxHandler(MaintainCategoryHandler):
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mclass = MCatalog()
        self.tmpl_router = 'category_ajax'
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
开发者ID:vaveee,项目名称:TorCMS,代码行数:12,代码来源:maintain_handler.py

示例10: LinkAjaxHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
class LinkAjaxHandler(LinkHandler):
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.user_name = self.get_current_user()
        self.tmpl_router = 'link_ajax'
        self.mlink = MLink()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
开发者ID:southwestjiaotongunivercity,项目名称:TorCMS,代码行数:13,代码来源:link_handler.py

示例11: App2ReplyHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
class App2ReplyHandler(Post2ReplyHandler):
    def initialize(self):
        self.muser = MUser()
        self.mreply = MReply()
        self.mreply2user = MReply2User()
        self.mpost2reply = MApp2Reply()

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
开发者ID:ironhot,项目名称:maplet,代码行数:13,代码来源:app2reply_handler.py

示例12: CategoryHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
class CategoryHandler(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.mpost2catalog = MPost2Catalog()
        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 == '':
            pass
        elif len(ip_arr) == 1:
            self.list_catalog(input)
        elif len(ip_arr) == 2:
            self.list_catalog(ip_arr[0], ip_arr[1])
        else:
            self.render('html/404.html')

    def list_catalog(self, cat_slug, cur_p=''):
        if cur_p == '':
            current_page_num = 1
        else:
            current_page_num = int(cur_p)

        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.catalog_record_number(cat_rec.uid)
        page_num = int(num_of_cat / config.page_num) + 1
        cat_name = cat_rec.name
        kwd = {
            'cat_name': cat_name,
            'cat_slug': cat_slug,
            'unescape': tornado.escape.xhtml_unescape,
            'title': cat_name,
        }

        self.render('{0}/catalog/list.html'.format(self.tmpl_name),
                    infos=self.mpost2catalog.query_pager_by_slug(cat_slug, current_page_num),
                    pager=tools.gen_pager_purecss('/category/{0}'.format(cat_slug), page_num, current_page_num),
                    userinfo=self.userinfo,
                    kwd=kwd)

    def get_random(self):
        return self.mpost.query_random()
开发者ID:net4nt,项目名称:TorCMS,代码行数:54,代码来源:category_handler.py

示例13: SearchHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
class SearchHandler(BaseHandler):
    def initialize(self):
        # analyzer = ChineseAnalyzer()
        # schema = Schema(title=TEXT(stored=True, analyzer = analyzer), path=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer))
        # ix = config.ix
        # self.searcher = config.searcher
        # self.parser = config.parser
        # self.parser = QueryParser("content", schema=ix.schema)

        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()
        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
        elif len(url_str) > 0:
            self.search(url_str)
        else:
            kwd = {
                'info': '页面未找到',
            }
            self.render('html/404.html', kwd=kwd)

    def post(self, url_str=''):
        keyword = self.get_argument('keyword')
        self.search(keyword)

    def to_find(self, ):
        kwd = {
            'pager': '',
        }
        self.render('tplite/post/find.html', topmenu='', kwd=kwd)
    def search(self, keyword):
        results = whoosh_search(keyword, 20)
        # reswhoosh_search.keyworde limit=3limit=30)
        kwd = {'title':'查找结果'}
        self.render('tplite/search/search.html',
                    kwd=kwd,
                    srecs = results,
                    )
开发者ID:Geoion,项目名称:TorCMS,代码行数:53,代码来源:search_handler.py

示例14: SearchHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
class SearchHandler(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.ysearch = yunsearch()
        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 == '':
            return
        elif len(url_arr) == 1:
            self.search(url_str)
        elif len(url_arr) == 2:
            self.search(url_arr[0], int(url_arr[1]))
        else:
            kwd = {
                'info': '页面未找到',
            }
            self.render('html/404.html', kwd=kwd)

    def post(self, url_str=''):
        keyword = self.get_argument('keyword')
        self.search(keyword)

    def search(self, keyword, p_index=1):
        res_all = self.ysearch.get_all_num(keyword)
        results = self.ysearch.search_pager(keyword, page_index=p_index, doc_per_page=20)
        page_num = int(res_all / 20)
        kwd = {'title': '查找结果',
               'pager': '',
               }
        self.render('{0}/search/search.html'.format(self.tmpl_name),
                    kwd=kwd,
                    srecs=results,
                    pager=tools.gen_pager_bootstrap_url('/search/{0}'.format(keyword), page_num, p_index),
                    cfg = config.cfg
                    )
开发者ID:xiaolushare,项目名称:TorCMS,代码行数:51,代码来源:search_handler.py

示例15: MapOverlayHandler

# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import get_by_id [as 别名]
class MapOverlayHandler(BaseHandler):
    def initialize(self):
        self.mequa = MApp()
        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(self, url_str=''):
        if len(url_str) > 0:
            url_arr = url_str.split('/')
        else:
            url_arr = []
        if len(url_arr) > 1:
            self.show_overlay(url_arr)
        else:
            kwd = {
                'title': '',
                'info': '',
            }
            self.render('html/404.html', kwd=kwd)

    def show_overlay(self, app_arr):
        '''
        打开App.
        '''
        app_info_arr = []
        for app_rr in app_arr:
            app_info_arr.append(self.mequa.get_by_uid(app_rr))
        kwd = {'url': 1,
               "cookie_str": '', }
        if 'fullscreen' in self.request.arguments:
            tmpl = 'app_theme/overlay/overlay_full.html'
        else:
            tmpl = 'app_theme/overlay/overlay.html'
        self.render(tmpl,
                    topmenu='',
                    kwd=kwd,
                    userinfo=self.userinfo,
                    unescape=tornado.escape.xhtml_unescape,
                    app_arr=app_info_arr,
                    app_str='/'.join(app_arr),
                    wcs_svr=config.wcs_svr,
                    )
开发者ID:sunyanhui,项目名称:maplet,代码行数:47,代码来源:overlay_handler.py


注:本文中的torlite.model.muser.MUser.get_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。