本文整理汇总了Python中models.users.Users.where方法的典型用法代码示例。如果您正苦于以下问题:Python Users.where方法的具体用法?Python Users.where怎么用?Python Users.where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.users.Users
的用法示例。
在下文中一共展示了Users.where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import where [as 别名]
def check(self):
from web import form
validList=(
form.Textbox("username", form.regexp(r".{3,20}$", 'User name: 3-20 chars')),
form.Password("password", form.regexp(r".{3,20}$", 'Password: 3-20 chars')),
)
if not self.validates(validList):
return self.error(self.errorMessage)
inputData = self.getInput()
if config.ADMIN_USERNAME == inputData['username'] and config.ADMIN_PASSWORD == inputData['password']:
self.setLogin(inputData['username'])
return self.success(msg='管理员登陆成功', url=self.makeUrl('/admin'))
else:
if not self.isInstalled():
return self.error(msg='用户登录失败, 系统未初始化!', url=self.makeUrl('/admin'))
userName = inputData['username']
password = hashlib.md5(inputData['password']).hexdigest()
try:
userObj = Users().select().where(Users.name == userName)
if userObj.where(Users.name == userName, Users.password == password).exists() == False:
return self.error(msg='用户登录失败,请检查用户名和密码是否匹配', url=self.makeUrl('/admin'))
self.setLogin(inputData['username'])
return self.success(msg='用户登陆成功', url=self.makeUrl('/admin'))
except Users.DoesNotExist:
return self.error(msg='用户登录失败,请检查用户名和密码是否匹配!', url=self.makeUrl('/admin'))
示例2: list
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import where [as 别名]
def list(self):
inputParams = self.getInput()
page = int(inputParams['page']) if inputParams.has_key('page') else 1
count = config.COUNT_PER_PAGE
offset= (page-1)*count if page > 0 else 0
current_user = Users.get(Users.name == self.isLogin())
usersList = Users().select()
if not self.isAdmin():
usersList = usersList.where(Users.id == current_user)
usersList = usersList.order_by(Users.id.desc())
pageString = self.getPageStr('/admin/users/list', page, count, usersList.count())
self.privData['USERS_LIST'] = usersList
self.privData['PAGE_STRING'] = pageString
return self.display('usersList')