本文整理汇总了Python中models.users.Users.all方法的典型用法代码示例。如果您正苦于以下问题:Python Users.all方法的具体用法?Python Users.all怎么用?Python Users.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.users.Users
的用法示例。
在下文中一共展示了Users.all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAdd
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import all [as 别名]
def testAdd(self):
users = Users()
before_count = len(users.all())
self.assertTrue(users.add(users.new(), persist=False))
after_count = len(users.all())
self.assertGreater(after_count, before_count)
self.assertEqual(before_count + 1, after_count)
示例2: testInit
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import all [as 别名]
def testInit(self):
users = Users()
self.assertIsInstance(users, ModelCollection)
self.assertGreater(users._items, 0)
self.assertIsInstance(users.all(), list)
for i in users.all():
self.assertIsInstance(i, User)
示例3: User
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import all [as 别名]
class User(Controller):
_users = None
def __init__(self):
super(User, self).__init__()
self._users = Users()
def get(self, id):
self._permissions.signed()
data = self._users.get(id)
if "password" in data:
del data["password"]
return data
def add(self, data):
self._permissions.signed()
return self._users.add(data)
def edit(self, id, data):
self._permissions.signed()
return self._users.edit(id, data)
def delete(self, id):
self._permissions.signed()
return self._users.delete(id)
def all(self, filter):
self._permissions.signed()
data = self._users.all(filter)
for item in data:
if "password" in item:
del item["password"]
return data
def current(self):
return self._users.check(session.get("email"), session.get("password"))
def signin(self, data):
user = self._users.check(data.get("email"), data.get("password"))
if "email" in user and "password" in user:
session["email"] = user["email"]
session["password"] = user["password"]
return self.current()
def signout(self):
session.pop('email', None)
session.pop('password', None)
return self.current()