• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tojauth.TOJAuth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_user_info_by_uid

    def get_user_info_by_uid(self, uid):
        cur = self.db.cursor()
        sqlstr = ('SELECT "uid", "username", "nickname", "email", "avatar", '
                  '"aboutme", "cover" FROM "USER" WHERE "uid" = %s;')
        sqlarr = (uid, )
        cur.execute(sqlstr, sqlarr)

        ret = None
        for data in cur:
            ret = {}
            ret['uid'] = data[0]
            ret['username'] = data[1]
            ret['nickname'] = data[2]
            ret['email'] = data[3]
            ret['avatar'] = data[4]
            ret['aboutme'] = data[5]
            ret['cover'] = data[6]

        uid = self.get_current_uid()
        if uid != ret['uid']:    
            try:
                TOJAuth.check_access_func(
                    self._accessid, TOJAuth.ACCESS_EXECUTE)
            except Exception:
                del ret['email']

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


示例2: get_notice

    def get_notice(self, noticeid):
        cur = self.db.cursor()
        sqlstr = ('SELECT "noticeid", "uid", "title", "content", "time", '
                  '"noticemodid", "metadata", "unread" FROM "NOTICE" WHERE '
                  '"noticeid" = %s;')
        sqlarr = (noticeid, )
        cur.execute(sqlstr, sqlarr)

        ret = None
        for data in cur:
            ret = {}
            ret['noticeid'] = data[0]
            ret['uid'] = data[1]
            ret['title'] = data[2]
            ret['content'] = data[3]
            ret['time'] = data[4]
            ret['noticemodid'] = data[5]
            ret['metadata'] = data[6]
            ret['unread'] = data[7]

        if ret == None:
            return None

        uid = mod.UserMg.get_current_uid()
        if uid != ret['uid']:
            TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_EXECUTE)

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


示例3: join_square

    def join_square(self, sqid):
        if(
            type(sqid) != int
        ):
            return 'Eparameter'

        uid = mod.UserMg.get_current_uid()
        if uid == None:
            return 'Euid'

        sq = self.get_square_info_by_sqid(sqid)
        if sq == None:
            return 'Eno_such_sqid'

        with TOJAuth.change_current_iden(self._idendesc):
            sqobj = self.load_square(sqid)

        result = sqobj.join_square(uid)

        if result == self.JOIN_REJECT:
            return 'Ereject'
        elif result == self.JOIN_PENDING:
            with TOJAuth.change_current_iden(self._idendesc):
                self._set_user_square_relation(uid, sqid, False)
            return {'active': False}
        elif result == self.JOIN_ACCEPT:
            with TOJAuth.change_current_iden(self._idendesc):
                self._set_user_square_relation(uid, sqid, True)
            
            return {'active': True}
        else:
            return 'Ejoin_sq_error'
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:32,代码来源:square.py


示例4: _create_square

    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,代码行数:34,代码来源:square.py


示例5: _create_problem

    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,代码行数:33,代码来源:problem.py


示例6: _del_mode

    def _del_mode(self, modeid):
        TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)

        cur = self.db.cursor()
        sqlstr = ('DELETE FROM "PMOD_TEST_MODE" WHERE "proid" = %s AND '
                  '"modeid" = %s;')
        sqlarr = (self._proid, modeid)
        cur.execute(sqlstr, sqlarr)
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:8,代码来源:pmod_test.py


示例7: _add_testmode

    def _add_testmode(self, testmodename, timelimit, memlimit):
        TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)

        cur = self.db.cursor()
        sqlstr = ('INSERT INTO "PMOD_TEST_TESTMODE" ("proid", "testmodename", '
                  '"timelimit", "memlimit") VALUES (%s, %s, %s, %s);')
        sqlarr = (self._proid, testmodename, timelimit, memlimit)
        cur.execute(sqlstr, sqlarr)
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:8,代码来源:pmod_test.py


示例8: _set_mode

    def _set_mode(self, modeid, content, testmodeid):
        TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)

        cur = self.db.cursor()
        sqlstr = ('UPDATE "PMOD_TEST_MODE" SET "content" = %s, '
                  '"testmodeid" = %s WHERE "proid" = %s AND "modeid" = %s;')
        sqlarr = (content, testmodeid, self._proid, modeid)
        cur.execute(sqlstr, sqlarr)
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:8,代码来源:pmod_test.py


示例9: set_problem

    def set_problem(self, proid, title):
        accessid = self.get_accessid_by_proid(proid)
        TOJAuth.check_access_func(accessid, TOJAuth.ACCESS_WRITE)

        cur = self.db.cursor()
        sqlstr = ('UPDATE "PROBLEM" SET "title" = %s WHERE "proid" = %s;')
        sqlarr = (title, proid)
        cur.execute(sqlstr, sqlarr)
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:8,代码来源:problem.py


示例10: _set_testmode

    def _set_testmode(self, testmodeid, testmodename, timelimit, memlimit):
        TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)

        cur = self.db.cursor()
        sqlstr = ('UPDATE "PMOD_TEST_TESTMODE" SET "testmodename" = %s, '
                  '"timelimit" = %s, "memlimit" = %s WHERE "proid" = %s AND '
                  '"testmodeid" = %s;')
        sqlarr = (testmodename, timelimit, memlimit, self._proid, testmodeid)
        cur.execute(sqlstr, sqlarr)
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:9,代码来源:pmod_test.py


示例11: set_square

    def set_square(self, sqid, title, start_time, end_time, intro, logo):
        accessid = self.get_accessid_by_sqid(sqid)
        TOJAuth.check_access_func(accessid, TOJAuth.ACCESS_WRITE)

        cur = self.db.cursor()
        sqlstr = ('UPDATE "SQUARE" SET "title" = %s, "start_time" = %s, '
                  '"end_time" = %s, "intro" = %s, "logo" = %s '
                  'WHERE "sqid" = %s;')
        sqlarr = (title, start_time, end_time, intro, logo, sqid)
        cur.execute(sqlstr, sqlarr)
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:10,代码来源:square.py


示例12: _set_square_category

    def _set_square_category(self, sqid, category):
        sq_accessid = self.get_accessid_by_sqid(sqid)
        TOJAuth.check_access_func(sq_accessid, TOJAuth.ACCESS_WRITE)

        if category == []:
            category = [0]

        cur = self.db.cursor()
        sqlstr = ('UPDATE "SQUARE" SET "cateid" = %s WHERE "sqid" = %s;')
        sqlarr = (category, sqid)
        cur.execute(sqlstr, sqlarr)
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:11,代码来源:square.py


示例13: _list_testdata

    def _list_testdata(self):
        TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)

        with TOJAuth.change_current_iden(self._idendesc):
            testdata_list = mod.TestdataMg.instance._list_testdata(self._proid)

        for test in testdata_list:
            del test['blobname']
            del test['proid']

        return testdata_list
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:11,代码来源:pmod_test.py


示例14: _create_testdata

    def _create_testdata(self, info, filekey, expire):
        TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)

        # Upload file

        blobname = 'TEST_BLOBNAME'

        with TOJAuth.change_current_iden(self._idendesc):
            testid = mod.TestdataMg.instance._add_testdata(
                blobname, expire, self._proid, info)

        return testid
开发者ID:taiwan-online-judge,项目名称:taiwan-online-judge,代码行数:12,代码来源:pmod_test.py


示例15: set_user_info

    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,代码行数:48,代码来源:user.py


示例16: _unregister_challenge_collector

    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,代码行数:7,代码来源:dispatch.py


示例17: _register_status_collector

    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,代码行数:7,代码来源:dispatch.py


示例18: set_testdata

    def set_testdata(self, testid, info, filekey = None, expire = None):
        if expire != None:
            expire = com.isoptime(expire)
            if expire == None:
                return 'Eparameter'

        if(
            type(testid) != int or
            type(info) != str or
            (filekey != None and type(filekey) != str)
        ):
            return 'Eparameter'

        with TOJAuth.change_current_iden(self._idendesc):
            test = mod.TestdataMg.instance._get_testdata(testid)

        if test == None:
            return 'Etestid'

        if test['proid'] != self._proid:
            return 'Eother_proid'

        result = self._set_testdata(testid, info, filekey, expire)

        if result == None:
            return 'Efailed'

        if result == False:
            return 'Eupload'

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


示例19: get_current_uid

 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,代码行数:7,代码来源:user.py


示例20: login

    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,代码行数:46,代码来源:user.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python token.endswith函数代码示例发布时间:2022-05-27
下一篇:
Python programs.docker_call函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap