本文整理汇总了Python中tojauth.TOJAuth.change_current_iden方法的典型用法代码示例。如果您正苦于以下问题:Python TOJAuth.change_current_iden方法的具体用法?Python TOJAuth.change_current_iden怎么用?Python TOJAuth.change_current_iden使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tojauth.TOJAuth
的用法示例。
在下文中一共展示了TOJAuth.change_current_iden方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: join_square
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
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'
示例2: _create_problem
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_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
示例3: _create_square
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_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;
示例4: set_testdata
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
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'
示例5: get_unseen_count
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def get_unseen_count(self):
uid = mod.UserMg.get_current_uid()
if uid == None:
return 'Euid'
with TOJAuth.change_current_iden(self._idendesc):
unseen_count = self._get_unseen_count(uid)
return {'unseen_count': unseen_count}
示例6: list_auth
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def list_auth(self):
uid = self.get_current_uid()
if uid == None:
return 'Euid'
idenid = self.get_idenid_by_uid(uid)
with TOJAuth.change_current_iden(self._idendesc):
auth_list = TOJAuth.instance.get_user_auth_list(idenid)
return auth_list
示例7: register
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def register(
self, username, password, nickname, email, avatar, aboutme, cover
):
if(
type(username) != str or
type(password) != str or
type(nickname) != str or
type(email) != str or
type(avatar) != str or
type(aboutme) != str or
type(cover) != str
):
return 'Eparameter'
if len(username) < self.USERNAME_LEN_MIN:
return 'Eusername_too_short'
elif len(username) > self.USERNAME_LEN_MAX:
return 'Eusername_too_long'
elif len(password) < self.PASSWORD_LEN_MIN:
return 'Epassword_too_short'
elif len(password) > self.PASSWORD_LEN_MAX:
return 'Epassword_too_long'
elif 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'
passhash = self._password_hash(password)
with TOJAuth.change_current_iden(self._idendesc):
try:
uid = self._create_user(
username, passhash, nickname, email, avatar, aboutme, cover
)
except psycopg2.IntegrityError:
return 'Eusername_exists'
return {'uid' : uid}
示例8: _list_testdata
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
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
示例9: _create_testdata
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
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
示例10: read_notice
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def read_notice(self, noticeid):
if(
type(noticeid) != int
):
return 'Eparameter'
notice = self.get_notice(noticeid)
if notice == None:
return 'Enoticeid'
with TOJAuth.change_current_iden(self._idendesc):
self.set_notice_unread(noticeid, False)
return 'Success'
示例11: del_mail
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def del_mail(self, mailid):
if(
type(mailid) != int
):
return 'Eparameter'
uid = mod.UserMg.get_current_uid()
if uid == None:
return 'Eno_uid'
with TOJAuth.change_current_iden(self._idendesc):
mail = self._get_mail(mailid)
if mail == None:
return 'Eno_such_mailid'
if mail['to_uid'] != uid:
TOJAuth.check_access(
self._accessid, TOJAuth.ACCESS_EXECUTE)(lambda x:x)(0)
with TOJAuth.change_current_iden(self._idendesc):
self._del_mail(mailid)
return 'Success'
示例12: quit_square
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def quit_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)
sqobj.quit_square(uid)
with TOJAuth.change_current_iden(self._idendesc):
self._del_user_square_relation(uid, sqid)
return 'Success'
示例13: get_mail_count
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def get_mail_count(self, mail_type = None):
uid = mod.UserMg.get_current_uid()
if uid == None:
return 'Eno_uid'
with TOJAuth.change_current_iden(self._idendesc):
tot_count = self._get_mail_count(uid, None, mail_type)
unread_count = self._get_mail_count(uid, True, mail_type)
ret = {
'tot_count': tot_count,
'unread_count': unread_count
}
return ret
示例14: del_notice
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def del_notice(self, noticeid):
if(
type(noticeid) != int
):
return 'Eparameter'
notice = self.get_notice(noticeid)
if notice == None:
return 'Enoticeid'
with TOJAuth.change_current_iden(self._idendesc):
self._del_notice(noticeid)
self.notify_client(notice['uid'])
return 'Success'
示例15: list_notice
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import change_current_iden [as 别名]
def list_notice(self, start_index = 0, list_num = NOTICE_LIST_NUM):
if(
type(start_index) != int or
type(list_num) != int
):
return 'Eparameter'
uid = mod.UserMg.get_current_uid()
if uid == None:
return 'Euid'
with TOJAuth.change_current_iden(self._idendesc):
ret = self._list_notice(uid, start_index, list_num)
return ret