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


Python TOJAuth.get_current_iden方法代码示例

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


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

示例1: _unregister_challenge_collector

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def _unregister_challenge_collector(self,name):
        link = TOJAuth.get_current_iden();
        linkclass = link.split('/')[1]
        if linkclass != 'backend':
            return 'Efailed'

        return self._unregister_collector(link,''.join(['challenge/',name]))
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:9,代码来源:dispatch.py

示例2: _register_status_collector

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def _register_status_collector(self,name):
        link = TOJAuth.get_current_iden()
        linkclass = link.split('/')[1]
        if linkclass != 'backend':
            return 'Efailed'

        return self._register_collector(link,''.join(['status/',name]))
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:9,代码来源:dispatch.py

示例3: _create_problem

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def _create_problem(self, title, pmodid):
        cur = self.db.cursor()
        sqlstr = ('INSERT INTO "PROBLEM" ("title", "pmodid", "accessid") '
                  'VALUES (%s, %s, %s) RETURNING "proid";')
        sqlarr = (title, pmodid, 0)
        cur.execute(sqlstr, sqlarr)

        proid = None
        for data in cur:
            proid = data[0]

        if proid == None:
            return None

        user_idenid = TOJAuth.get_current_iden()['idenid']
        with TOJAuth.change_current_iden(self._idendesc):
            accessid = TOJAuth.instance.create_access(user_idenid)

        sqlstr = ('UPDATE "PROBLEM" SET "accessid" = %s WHERE "proid" = %s;')
        sqlarr = (accessid, proid)
        cur.execute(sqlstr, sqlarr)

        TOJAuth.instance.set_access_list(
            accessid, TOJAuth.ROLEID_PROBLEM_ADMIN_GROUP, 
            TOJAuth.ACCESS_ALL
        )

        pmodname = self.get_pmodname_by_pmodid(pmodid)
        pmod = mod.load_pmod(pmodname)
        
        pmod.create_problem_data(proid)

        return proid
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:35,代码来源:problem.py

示例4: get_current_uid

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
 def get_current_uid():
     user_iden = TOJAuth.get_current_iden()
     try:
         uid = user_iden['uid']
     except KeyError:
         return None
     return uid
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:9,代码来源:user.py

示例5: _create_square

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def _create_square(self, title, sqmodid, intro, logo):
        cur = self.db.cursor()
        sqlstr = ('INSERT INTO "SQUARE" ("title", "hidden", "sqmodid", '
                  '"intro", "logo", "accessid") VALUES (%s, %s, %s, %s, '
                  '%s, %s) RETURNING "sqid";')
        sqlarr = (title, False, sqmodid, intro, logo, 0)
        cur.execute(sqlstr, sqlarr)

        sqid = None
        for data in cur:
            sqid = data[0]

        if sqid == None:
            return None

        user_idenid = TOJAuth.get_current_iden()['idenid']
        with TOJAuth.change_current_iden(self._idendesc):
            accessid = TOJAuth.instance.create_access(user_idenid)

        sqlstr = ('UPDATE "SQUARE" SET "accessid" = %s WHERE "sqid" = %s;')
        sqlarr = (accessid, sqid)
        cur.execute(sqlstr, sqlarr)

        TOJAuth.instance.set_access_list(
            accessid, TOJAuth.ROLEID_SQUARE_ADMIN_GROUP, 
            TOJAuth.ACCESS_ALL
        )

        sqmodname = self.get_sqmodname_by_sqmodid(sqmodid)
        sqmod = mod.load_sqmod(sqmodname)

        sqmod.create_square_data(sqid)

        return sqid;
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:36,代码来源:square.py

示例6: set_user_info

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def set_user_info(self, uid, nickname, email, avatar, aboutme, cover):
        if(
            type(uid) != int or
            type(nickname) != str or
            type(email) != str or
            type(avatar) != str or
            type(aboutme) != str or
            type(cover) != str
        ):
            return 'Eparameter'

        if len(nickname) < self.NICKNAME_LEN_MIN:
            return 'Enickname_too_short'
        elif len(nickname) > self.NICKNAME_LEN_MAX:
            return 'Enickname_too_long'
        elif len(email) < self.EMAIL_LEN_MIN:
            return 'Eemail_too_short'
        elif len(email) > self.EMAIL_LEN_MAX:
            return 'Eemail_too_long'
        elif len(avatar) < self.AVATAR_LEN_MIN:
            return 'Eavatar_too_short'
        elif len(avatar) > self.AVATAR_LEN_MAX:
            return 'Eavatar_too_long'
        elif len(aboutme) < self.ABOUTME_LEN_MIN:
            return 'Eaboutme_too_short'
        elif len(aboutme) > self.ABOUTME_LEN_MAX:
            return 'Eaboutme_too_long'
        elif len(cover) < self.COVER_LEN_MIN:
            return 'Ecover_too_short'
        elif len(cover) > self.COVER_LEN_MAX:
            return 'Ecover_too_long'

        idenid = self.get_idenid_by_uid(uid)
        if idenid == None:
            return 'Eno_such_uid'

        if idenid != TOJAuth.get_current_iden()['idenid']:
            TOJAuth.check_access(
                self._accessid, TOJAuth.ACCESS_EXECUTE)(lambda x:x)(0)

        cur = self.db.cursor()
        sqlstr = ('UPDATE "USER" SET "nickname" = %s, "email" = %s, '
                  '"avatar" = %s, "aboutme" = %s, "cover" = %s WHERE '
                  '"uid" = %s;')
        sqlarr = (nickname, email, avatar, aboutme, cover, uid)
        cur.execute(sqlstr, sqlarr)

        return 'Success'
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:50,代码来源:user.py

示例7: login

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def login(self, username, password):
        if(
            type(username) != str or
            type(password) != str
        ):
            return 'Eparameter'

        uid = self.get_uid_by_username(username)
        if uid == None:
            return 'Elogin_failed'

        passhash = self._password_hash(password)

        cur = self.db.cursor()
        sqlstr = ('SELECT "idenid" FROM "USER" WHERE "uid" = %s '
                  'AND "passhash" = %s;')
        sqlarr = (uid, passhash)
        cur.execute(sqlstr, sqlarr)

        idenid = None
        for data in cur:
            idenid = data[0]

        if idenid == None:
            return 'Elogin_failed'
        
        client_link = TOJAuth.get_current_iden()['link']
        with TOJAuth.change_current_iden(self._idendesc):
            stat,data = Proxy.instance.call(self.get_link('center') + 'core/',
                                            'create_iden',
                                            10000,
                                            client_link,
                                            idenid,
                                            TOJAuth.ROLETYPE_USER,
                                            {'uid' : uid})

        if stat == False:
            return 'Einternal'

        ret = {
            'idendesc' : data,
            'uid' : uid,
            'hash' : self._uid_passhash_hash(uid, passhash)
        }

        return ret
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:48,代码来源:user.py

示例8: cookie_login

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def cookie_login(self, uid, uphash):
        if(
            type(uid) != int or
            type(uphash) != str
        ):
            return 'Eparameter'

        idenid = None
        real_uphash = None

        cur = self.db.cursor()
        sqlstr = ('SELECT "idenid", "passhash" FROM "USER" WHERE "uid" = %s;')
        sqlarr = (uid, )
        cur.execute(sqlstr, sqlarr)

        for data in cur:
            idenid = data[0]
            real_uphash = self._uid_passhash_hash(uid, data[1])

        if idenid == None:
            return 'Elogin_failed'

        if real_uphash != uphash:
            return 'Elogin_failed'

        client_link = TOJAuth.get_current_iden()['link']
        with TOJAuth.change_current_iden(self._idendesc):
            stat,data = Proxy.instance.call(self.get_link('center') + 'core/',
                                            'create_iden',
                                            10000,
                                            client_link,
                                            idenid,
                                            TOJAuth.ROLETYPE_USER,
                                            {'uid' : uid})

        if stat == False:
            return 'Einternal'

        ret = {
            'idendesc' : data,
            'uid' : uid,
            'hash' : uphash
        }

        return ret
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:47,代码来源:user.py

示例9: change_user_password

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def change_user_password(self, uid, old_password, new_password):
        if(
            type(uid) != int or
            type(old_password) != str or
            type(new_password) != str
        ):
            return 'Eparameter'

        if len(new_password) < self.PASSWORD_LEN_MIN:
            return 'Epassword_too_short'
        elif len(new_password) > self.PASSWORD_LEN_MAX:
            return 'Epassword_too_long'
        
        idenid = self.get_idenid_by_uid(uid)
        if idenid == None:
            return 'Eno_such_uid'

        if idenid != TOJAuth.get_current_iden()['idenid']:
            TOJAuth.check_access(
                self._accessid, TOJAuth.ACCESS_EXECUTE)(lambda x:x)(0)

        old_passhash = self._password_hash(old_password)

        cur = self.db.cursor()
        sqlstr = ('SELECT "idenid" FROM "USER" WHERE "uid" = %s '
                  'AND "passhash" = %s;')
        sqlarr = (uid, old_passhash)
        cur.execute(sqlstr, sqlarr)

        idenid = None
        for data in cur:
            idenid = data[0]

        if idenid == None:
            return 'Ewrong_old_password'

        new_passhash = self._password_hash(new_password)

        sqlstr = ('UPDATE "USER" SET "passhash" = %s WHERE "uid" = %s;')
        sqlarr = (new_passhash, uid)
        cur.execute(sqlstr, sqlarr)

        return 'Success'
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:45,代码来源:user.py

示例10: _lookup_link

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def _lookup_link(self,link):
        try:
            #a = int(TOJAuth.get_current_iden()['linkid'])
            #b = int(linkid)

            #if b > a:
            #    worker = self._worker_linkidmap[str(a + 1)]

            #else:
            #    worker = self._worker_linkidmap[str(a - 1)]

            if TOJAuth.get_current_iden()['link'].split('/')[1] != 'client':
                linkclass,linkid = link.split('/')[1:3]

                if linkclass == 'client':
                    backend_link = self._client_linkmap[link]['backend_link']
                    worker = self._worker_linkmap[backend_link]
                    
                    sock_ip,sock_port = worker.sock_addr
                    return {
                        'worker_link':worker.link,
                        'sock_ip':sock_ip,
                        'sock_port':sock_port
                    }

                else:
                    worker = self._worker_linkmap[link]
                    
                    sock_ip,sock_port = worker.sock_addr
                    return {
                        'worker_link':worker.link,
                        'sock_ip':sock_ip,
                        'sock_port':sock_port
                    }

                return None

        except KeyError:
            return None
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:41,代码来源:center_server.py

示例11: _test_get_client_list

# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import get_current_iden [as 别名]
    def _test_get_client_list(self,talk,talk2):
        stat,ret = Proxy.instance.call(TOJAuth.get_current_iden()['link'] + 'test/route/','80s',1000,'attation','mega')
        print(ret)

        return list(self._client_linkmap.items())
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:7,代码来源:backend_server.py


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