當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。