本文整理汇总了Python中validator.Validator.session方法的典型用法代码示例。如果您正苦于以下问题:Python Validator.session方法的具体用法?Python Validator.session怎么用?Python Validator.session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.Validator
的用法示例。
在下文中一共展示了Validator.session方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: usersites
# 需要导入模块: from validator import Validator [as 别名]
# 或者: from validator.Validator import session [as 别名]
def usersites(self, email, session_id):
Validator.email(email)
Validator.session(session_id)
user = self.user.get(email)
self.user.validate_session(user['session'], session_id)
return self.site.get_user_urls(user['id'])
示例2: sessions
# 需要导入模块: from validator import Validator [as 别名]
# 或者: from validator.Validator import session [as 别名]
def sessions(self, email, session_id):
Validator.email(email)
Validator.session(session_id)
sessions = self.user.get(email)['session']
found = False
for session in sessions:
if session['id'] == session_id and 'stop' not in session:
found = True
if not found:
raise RiverException('The session is not valid for this account.')
return sessions
示例3: addusertosite
# 需要导入模块: from validator import Validator [as 别名]
# 或者: from validator.Validator import session [as 别名]
def addusertosite(self, email, session_id, url):
Validator.email(email)
Validator.session(session_id)
Validator.url(url)
user = self.user.get(email)
self.user.validate_session(user['session'], session_id)
if not self.site.exists(url):
self.site.add_site(url)
if url in self.site.get_user_urls(user['id']):
raise RiverException(_('The site has already been added to this user.'))
self.site.add_user(url, user['id'])
示例4: signout
# 需要导入模块: from validator import Validator [as 别名]
# 或者: from validator.Validator import session [as 别名]
def signout(self, email, session_id):
Validator.email(email)
Validator.session(session_id)
sessions = self.user.get(email)['session']
found = False
for count, session in enumerate(sessions):
if session['id'] == session_id:
if 'stop' in session:
raise RiverException('The session has already been ended.')
found = True
session_stop = datetime.utcnow().isoformat()
self.user.update_array(email, 'session', count, 'stop', session_stop)
if not found:
raise RiverException('The session is not valid for this account.')