本文整理汇总了Python中user_models.UserData.all方法的典型用法代码示例。如果您正苦于以下问题:Python UserData.all方法的具体用法?Python UserData.all怎么用?Python UserData.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user_models.UserData
的用法示例。
在下文中一共展示了UserData.all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_creation_with_existing_username
# 需要导入模块: from user_models import UserData [as 别名]
# 或者: from user_models.UserData import all [as 别名]
def test_creation_with_existing_username(self):
self.flush([self.insert_user("larry", "[email protected]", "larry")])
self.assertEqual(1, UserData.all().count())
self.assertEqual("larry", UserData.all()[0].user_id)
self.assertEqual("larry", UserData.all()[0].username)
self.assertTrue(self.insert_user("larry2", "[email protected]",
"larry") is None)
示例2: test_creation_with_password
# 需要导入模块: from user_models import UserData [as 别名]
# 或者: from user_models.UserData import all [as 别名]
def test_creation_with_password(self):
self.flush([self.insert_user("larry",
"[email protected]",
"larry",
"Password1")])
self.assertEqual(1, UserData.all().count())
retrieved = UserData.all()[0]
self.assertEqual("larry", retrieved.user_id)
self.assertTrue(retrieved.validate_password("Password1"))
self.assertFalse(retrieved.validate_password("Password2"))
示例3: test_creation_without_username
# 需要导入模块: from user_models import UserData [as 别名]
# 或者: from user_models.UserData import all [as 别名]
def test_creation_without_username(self):
added = [
self.insert_user("larry", "[email protected]"),
self.insert_user("curly", "[email protected]"),
self.insert_user("moe", "[email protected]"),
]
# We don't care about consistency policy issues - we just want proper
# counts and such.
self.flush(added)
self.assertEqual(3, UserData.all().count())
self.assertEqual(set(["larry", "curly", "moe"]),
set(user.user_id for user in UserData.all()))
# "Re-adding" moe doesn't duplicate.
self.flush([self.insert_user("moe", "[email protected]")])
self.assertEqual(3, UserData.all().count())
示例4: get
# 需要导入模块: from user_models import UserData [as 别名]
# 或者: from user_models.UserData import all [as 别名]
def get(self):
developers = UserData.all()
developers.filter('developer = ', True).fetch(1000)
template_values = {
"developers": developers,
"selected_id": "devs",
}
self.render_jinja2_template('devpanel/devs.html', template_values)
示例5: get_coaches_all_students
# 需要导入模块: from user_models import UserData [as 别名]
# 或者: from user_models.UserData import all [as 别名]
def get_coaches_all_students():
users = UserData.all()
coaches_dict = {}
for user in users:
for coach in user.coaches:
if not coach in coaches_dict:
coaches_dict[coach] = [user.user_email]
else:
coaches_dict[coach].append(user.user_email)
return coaches_dict
示例6: get_coaches_students_count
# 需要导入模块: from user_models import UserData [as 别名]
# 或者: from user_models.UserData import all [as 别名]
def get_coaches_students_count():
coaches_dict = get_coaches_all_students()
coaches_list = []
for coach_email, students_list in coaches_dict.items():
coach = UserData.all().filter("user_email = ", coach_email).get()
if coach:
coach_dict = {
"joined": str(coach.joined),
"last_activity": str(coach.last_activity),
"coach_email": coach_email,
"number_of_students": len(students_list)
}
coaches_list.append(coach_dict)
return coaches_list
示例7: main
# 需要导入模块: from user_models import UserData [as 别名]
# 或者: from user_models.UserData import all [as 别名]
def main(db_filename):
"""Start a dev_appserver, create db entries on it, and exit."""
try:
with open(db_filename):
filename=db_filename
except IOError:
filename=None
handler_test_utils.start_dev_appserver(db=filename)
try:
stub()
from user_models import UserData
import csv
if filename == None:
print >>sys.stderr, 'Making users'
Users()
print >>sys.stderr, 'Making users:Done'
users = UserData.all().fetch(100)
with open('users.csv', 'wb') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=' ',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
for u in users:
print u.nickname
spamwriter.writerow([u.nickname])
print >>sys.stderr, 'Done! Output in %s' % db_filename
if filename == None:
shutil.copy(os.path.join(handler_test_utils.tmpdir,
'datastore', 'test.sqlite'),
db_filename)
finally:
# We keep around the tmpdir for debugging/etc
handler_test_utils.stop_dev_appserver(delete_tmpdir=False)