当前位置: 首页>>代码示例>>Python>>正文


Python UserData.all方法代码示例

本文整理汇总了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)
开发者ID:PaulWagener,项目名称:khan-website,代码行数:10,代码来源:user_models_test.py

示例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"))
开发者ID:PaulWagener,项目名称:khan-website,代码行数:12,代码来源:user_models_test.py

示例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())
开发者ID:PaulWagener,项目名称:khan-website,代码行数:18,代码来源:user_models_test.py

示例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) 
开发者ID:PaulWagener,项目名称:KhanLatest,代码行数:11,代码来源:handlers.py

示例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
开发者ID:Hao-Hsuan,项目名称:KhanLatest,代码行数:12,代码来源:coaches_utils.py

示例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
开发者ID:Hao-Hsuan,项目名称:KhanLatest,代码行数:16,代码来源:coaches_utils.py

示例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)
开发者ID:Hao-Hsuan,项目名称:KhanLatest,代码行数:38,代码来源:mytest_db.py


注:本文中的user_models.UserData.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。