• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python users.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.users.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_all_user_blogs

def get_all_user_blogs(user_id=None):

    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()
    return render_template('/user_page/user_blogs.html', blogs=blogs, email=user._email)
开发者ID:EgbieAndersonUku1,项目名称:simpleWebBlog,代码行数:8,代码来源:app.py


示例2: fake_users

def fake_users(session, request):
    u = User()
    u.username = 'test_user'
    u.password = 'test_password'
    session.add(u)
    session.commit()

    yield u
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:8,代码来源:conftest.py


示例3: setup

def setup():
    db.create_all(app=manager.app)
    with manager.app.app_context():
        u = User()
        u.username = 'admin'
        u.password = 'admin123'
        db.session.add(u)
        db.session.commit()
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:8,代码来源:run.py


示例4: create_user

def create_user():
    name = request.form.get('username', None)
    password = request.form.get('password', None)
    if all([name, password]):
        u = User()
        u.password = password
        u.username = name
        db.session.add(u)
        db.session.commit()
        return 'OK', 200
    return 'Error', 400
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:11,代码来源:views.py


示例5: done

    def done(self):
        #make sure the user doesn't already exist
        u = User.by_name(self.username)
        if u:
            msg = 'That user already exists.'
            self.render('signup-form.html', error_username = msg)
        else:
            u = User.register(self.username, self.password, self.email)
            u.put()

            self.login(u)
            self.redirect('/')
开发者ID:aliismayilov,项目名称:udacity-webpy,代码行数:12,代码来源:signup.py


示例6: user_login

def user_login():

    if request.method == 'GET':
        #return render_template('/login/login.html')
        return login()
    else:
        email  = request.form['email']
        passwd = request.form['password']
        if User.login_valid(email, passwd):
            User.login(email)
            return render_template('/user_page/user_profile_page.html', email=session['email'])
        else:
            session['email'] = None
            return login()
开发者ID:EgbieAndersonUku1,项目名称:simpleWebBlog,代码行数:14,代码来源:app.py


示例7: test_users

def test_users(session):
    u = User()
    u.username = 'test_user'
    u.password = 'testpassword'

    session.add(u)
    session.commit()

    t = session.query(User).filter(User.username == 'test_user').first()

    assert t is not None
    assert u == t
    assert t.password == u.password
    assert t.api_key is None
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:14,代码来源:test_models.py


示例8: register_user

def register_user():

    if request.method == 'GET':
        return render_template('/register/register.html')
    else:
        email  = request.form['email']
        passwd = request.form['password']

        if User.get_by_email(email):
            return 'user already exists'
        else:
            User.register(email, passwd)

    return render_template('/user_page/user_profile_page.html', email=session['email'])
开发者ID:EgbieAndersonUku1,项目名称:simpleWebBlog,代码行数:14,代码来源:app.py


示例9: login

def login():
    user_name = request.form['username'];
    password = request.form['password'];
    for user in User.objects(user_name=user_name):
        if(user.password == password):
            return json.dumps({"result_code":1, "result_message":"Login succeded"})
    return json.dumps({"result_code":0, "result_message":"Login failed"})
开发者ID:huynq-tk-ios3,项目名称:iliat-erp-dump,代码行数:7,代码来源:app.py


示例10: post

    def post(self):
        """Checks if user already exists, otherwise creates a new User in db"""
        args = post_parser.parse_args()
        user = User(args.email, args.password)

        # Check if already registered
        user_already_exists = User.query.filter(User.email == args.email).first()
        if user_already_exists:
            return {'success': False, 'message': 'That user already exists', 'data': None}

        # Try saving the user to db
        try:
            user.save()
            return {'success': True, 'message': 'User successfully added', 'data': None}
        except ValueError as e:
            return {'success': False, 'message': str(e), 'data': None}
开发者ID:alexandercrosson,项目名称:braise,代码行数:16,代码来源:users.py


示例11: get_friends_list

    def get_friends_list(self, user):
        twitterApi = Twitter.getInstance()
        friends_list = []
        l = []
        
        # Very bad hack. Need to move all these to model.validate
        try:
            # Twitter API doesn't allow to get all friends infor at once.
            # Instead you can only get all friends Ids and the use UserLookup
            # to get full user infor but only in batches of 100 user at once
            follow_list = twitterApi.api.GetFriendIDs(user.twitter)["ids"]

            while len(follow_list) > 100:
                l = l + twitterApi.api.UsersLookup(follow_list[0:100])
                follow_list = follow_list[100:len(follow_list)]
            l = l + twitterApi.api.UsersLookup(follow_list[0:len(follow_list)])

            for friend in l:
                friend_in_db = User.all().filter("twitter =", friend.screen_name)
                if friend_in_db.count() == 1:
                    friends_list.append(friend.screen_name)
            
        except TwitterError: 
            friends_list = ['not_authorized']

        return friends_list
开发者ID:dazbur,项目名称:languagebot,代码行数:26,代码来源:profile.py


示例12: test_clustering

def test_clustering():
    me = User.create(name="Jon")
    for x in range(10):
        Photo.create(user_id=me.user_id, name=str(x))

    for x in Photo.objects(user_id=me.user_id):
        print x.name
开发者ID:cqlengine,项目名称:tutorial,代码行数:7,代码来源:test_get_photos.py


示例13: test_polymorphism

def test_polymorphism():
    me = User.create(name="pete")
    Photo.create(user_id=me.user_id, name="sunset")
    Video.create(user_id=me.user_id, name="kickball")

    for content in Video.objects(user_id=me.user_id):
        print content
开发者ID:cqlengine,项目名称:tutorial,代码行数:7,代码来源:test_get_photos.py


示例14: prepareEmailMessagesGenerator

def prepareEmailMessagesGenerator():
    # This must be run after buildDailyList
    # Since only there a daily message limit is applied
    # though, this limit can be different for emails
    path_current = os.path.dirname(__file__)
    root_path = os.path.split(path_current)[0]
    view_path = root_path + "/views/daily_email.html"

    today = datetime.date.today()
    emails_dict = {}
    for user in User.all().filter("account_status =", "enabled").\
        filter("use_daily_email =", "yes"):

        parameters = {}
        parameters["dict_row"] = []
        for lli in LearnList.all().\
            filter("next_serve_date =", today).\
            filter("twitter_user =", user.twitter):
            l = []
            l.append(lli.dict_entry.word + " " + lli.dict_entry.pronounce)
            l.append(lli.dict_entry.meaning)
            parameters["dict_row"].append(l)
        emails_dict["email"] = user.email
        emails_dict["message"] = template.\
            render(view_path, parameters)
        yield emails_dict
开发者ID:dazbur,项目名称:languagebot,代码行数:26,代码来源:learnlist.py


示例15: users

	def users(self):
		"""
			List users, for the asmins
		"""
		tmpl = config.lookup.get_template("users.html")
		ulist = list(User.select())
		return tmpl.render(env=config.htmlEnv, users=ulist, session=cherrypy.session)
开发者ID:thomas-maurice,项目名称:quotes,代码行数:7,代码来源:login.py


示例16: get

    def get(self):
        async_client = AsyncHTTPClient()
        auth_code = self.get_argument("code", None)
        if auth_code:
            # 第一步 获取access_token
            auth_token_url = self.__build_auth_token_url(auth_code)
            token_response = yield async_client.fetch(auth_token_url)
            access_token, refresh_token = self.__parse_token(token_response)

            # 第二不 得到用户身份信息
            auth_me_url = self.__build_auth_me_url(access_token)
            open_response = yield async_client.fetch(auth_me_url)
            openid = self.__parse_me(open_response)

            # 第三布 获取用户基本信息
            auth_user_url = self.__build_auth_user_url(access_token, openid)
            user_info = yield async_client.fetch(auth_user_url)
            user = self.__parse_user(user_info, access_token, refresh_token, openid)
            # 确认用户是否已经登录过
            try:
                user = User.objects(type='qq', uid=openid)[0]
            except Exception as ex:
                app_log.exception(ex)
            finally:
                user.save()
                self.set_secure_cookie('userid', str(user.id))
                self.set_secure_cookie('type', 'qq')
                self.redirect("/")
        else:
            # 登录失败,跳转到登录页面
            self.redirect("/sigin")
开发者ID:yunlzheng,项目名称:PDFLabs,代码行数:31,代码来源:__init__.py


示例17: createUser

 def createUser(self, twitter_user, account_status, messages_per_day):
     user = User()
     user.twitter = twitter_user
     user.username = twitter_user
     user.account_status = account_status
     user.messages_per_day = messages_per_day
     user.total_points = 0
     user.put()
     return user
开发者ID:dazbur,项目名称:languagebot,代码行数:9,代码来源:tests.py


示例18: getUsers

def getUsers():
    userlist = []
    for user in User.all().order("-total_points").run():
        c = Dictionary.all().\
            filter("twitter_user =", user.twitter).count()
        userlist.append({"username": user.twitter, "points": user.total_points,
                        "wordscount": c})
    return json.dumps(userlist)
开发者ID:dazbur,项目名称:languagebot,代码行数:8,代码来源:rpchandler.py


示例19: test_isset_user

    def test_isset_user(self, user_data):
        user = self.add_user(**user_data)

        isset_user = User.isset_user(**user_data)

        self.assertTrue(isset_user)
        self.assertEqual(isset_user['user_name'], user.name)
        self.assertEqual(isset_user['user_id'], user.id)
开发者ID:pasichnyk-oleh,项目名称:pchat,代码行数:8,代码来源:user_test.py


示例20: get_user

 def get_user(self):
     """
     Gets the current user that is logged on based on session data
     """
     session_id = self.get_cookie('session')
     if session_id is not None:
         return User.all().filter('session =', session_id) \
             .filter('session_expiry >', datetime.datetime.now()).get()
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:8,代码来源:base.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python users.Users类代码示例发布时间:2022-05-27
下一篇:
Python user.UserModel类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap