本文整理汇总了Python中models.User.User.valid方法的典型用法代码示例。如果您正苦于以下问题:Python User.valid方法的具体用法?Python User.valid怎么用?Python User.valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.User.User
的用法示例。
在下文中一共展示了User.valid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import valid [as 别名]
def index():
user = FacebookClient().process(bottle.request.GET['code'])
if user:
users = EntityManager(_DBCON).getAll(User, filterCriteria={'facebookUserId':user['id']})
if users:
_id = users[0]._id
else:
_id = None
u = User(_DBCON, _id=_id)
u.username = user['name']
u.password = user['id']
u.valid = False
u.facebookUserId = user['id']
u.save()
s = Session(_DBCON)
s.userid = u._id
s.ip = bottle.request.get('REMOTE_ADDR')
s.useragent = bottle.request.get('HTTP_USER_AGENT')
s.save()
s.set_cookie()
bottle.redirect('/')
else:
bottle.redirect('/login')
示例2: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import valid [as 别名]
def create_user(self, email='[email protected]', password='passpass', valid=True):
u = User(self.conn)
u.email = email
u.password = password
u.valid = valid
u.save()
return u
示例3: create_activated_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import valid [as 别名]
def create_activated_user(self):
"""
shortcut to save having to activate the user each time we
create one
"""
u = User(_DBCON)
u.email = self.EMAIL
u.password = self.PASSWORD
u.valid = True
u.save()
return u
示例4: testValid
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import valid [as 别名]
def testValid(self):
email = '[email protected]'
for k, v in uv.iteritems():
for p, t in pv.iteritems():
valid, err = User.valid(k, email, p)
self.assertEqual(valid, v and t, "{} - {}".format(k, p))