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

Python models.User类代码示例

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

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



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

示例1: removeApprovals

 def removeApprovals(article,user1=None):
     page=0;limit=100
     
     if user1: 
         users=[user1]
     else:# if no user specified, then apply all users
         users=User.all().fetch(limit,page*limit)
         
     while users:
         for user in users:
             approvals=ArticleLib.getApprovals(article, user)
             if approvals:
                 logging.info("TODO: lock the ArticleCategory records for update")
                 article_cats=ArticleLib.getCategories(article)
                 if article_cats:
                     for article_cat in article_cats:
                         if approvals.has_key(article_cat.category):
                             article_cat.r2=article_cat.r2-(approvals[article_cat.category].score/100)
                         else:
                             article_cat.r2=article_cat.r2-(0.01/100)
                         article_cat.save()
                         
                         
         page=page+1
         if not user1:
             users=User.all().fetch(limit,page*limit)
     
     return None
开发者ID:saidwords,项目名称:syytacit,代码行数:28,代码来源:ArticleLib.py


示例2: post

 def post(self):
     self.response.headers["Content-Type"] = "application/json"
     email = self.request.get("email")
     password = self.request.get("password")
     try:
         user = User.get_by_auth_password(email, password)
     except:
         self.response.write(resp.fail_pass())
         return
     if not user:
         self.response.write(resp.fail_pass())
     else:
         token = User.create_auth_token(user.key.id())
         self.response.write(
             resp.success(
                 {
                     "Token": token,
                     "User": {
                         "firstname": user.firstname,
                         "lastname": user.lastname,
                         "email": user.auth_ids[0],
                         "id": user.key.id(),
                     },
                 }
             )
         )
开发者ID:jaredwindover,项目名称:SetScouter,代码行数:26,代码来源:Session.py


示例3: post

 def post(self):
     self.response.headers['Content-Type'] = 'application/json'
     firstname = self.request.get('firstname')
     lastname = self.request.get('lastname')
     email = self.request.get('email')
     password = self.request.get('password')
     work, info = User.create_user(
         email,
         firstname=firstname,
         lastname=lastname,
         password_raw=password
     )
     if not work:
         self.response.write(resp.fail(
             'email',
             'Email address already exists'
         ))
     else:
         user = info
         token = User.create_auth_token(user.key.id())
         self.response.write(resp.success({
             'Token' : token,
             'User' : {
                 'firstname' : user.firstname,
                 'lastname' : user.lastname,
                 'email' : user.auth_ids[0],
                 'id' : user.key.id()
             }
         }))
开发者ID:jaredwindover,项目名称:SetScouter,代码行数:29,代码来源:User.py


示例4: set_emailAction

 def set_emailAction(self,email):
     if self.user:
         current_email=self.user.getEmail()
         if current_email!=email:
             user=User().get_by_auth_id(self.user.username)
             user.email_address=email
             user.put()
             
     model={"email":email}
     return model 
开发者ID:saidwords,项目名称:syytacit,代码行数:10,代码来源:UserController.py


示例5: get

 def get(self):
   users = User.query().fetch()
   tasklist_name = self.request.get('tasklist_name', DEFAULT_TASKLIST_NAME)
   tasks_query = Task.query(ancestor=tasklist_key(tasklist_name)).order(-Task.date)
   tasks = tasks_query.fetch()
   
   self.render_template('authenticated.html', locals())
开发者ID:lydiachen,项目名称:ellyphant,代码行数:7,代码来源:main.py


示例6: post

 def post(self):
     # set headers
     self.response.headers.add_header('Content-Type', 'application/json')
     form = LoginForm(formdata=webob.multidict.MultiDict(json.loads(self.request.body or '{}')))
     form.validate()
     if form.errors:
         self.response.set_status(400)
         self.response.write(json.dumps(form.errors))
     else:
         try:
             User.get_by_auth_password(form.email.data, form.password.data)
             self.session['user'] = form.email.data
             self.response.write(json.dumps({'success': "Logged in"}))
         except Exception:
             self.response.set_status(400)
             self.response.write(json.dumps({'error': "Login failed"}))
开发者ID:carlitux,项目名称:test-gae,代码行数:16,代码来源:main.py


示例7: get_user_address

 def get_user_address(self):
     user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
     if user:
         if user.address:
             return user.address.address_from
     else:
         return ''
开发者ID:chuydb,项目名称:usocialmaps,代码行数:7,代码来源:models.py


示例8: send_rfps_to_subscribers

    def send_rfps_to_subscribers(self):
        """
            As the function name implies, all subscribed users will receive an RFP update to their
            email accounts. By comparing an RFP's parse date to a subscription's last update date,
            we ensure dups aren't being sent out.

            Returns a list of results based on what happened for each subscription.

        """

        results = []
        subs = Subscription.all()
        for sub in subs:

            try:

                # Grab what user info, add first, last name later
                user = User.query(query.FilterNode('username', '=', sub.username)).get()

                # Ensure the the sub's username is associated with an actual account
                # by checking if the email exists.
                if user.email:
                    self._send_rfps_to_subscribers(sub, user.first_name, user.email, results)
                else:
                    msg = 'No email found for username: %s  and keyword: %s' % (sub.username, sub.keyword)

                    logging.info(msg)
                    results.append('Error: ' + msg)
            except:
                msg = 'Problem with sending RFPs for some subscription, maybe bad user object'
                logging.info(msg)
                results.append('Error: ' + msg)


        return results
开发者ID:dmkc,项目名称:rfpow,代码行数:35,代码来源:email.py


示例9: create_random_article_approvalsAction

 def create_random_article_approvalsAction(self):
     self.checkEnv()
     all_articles=ArticleModel.all().fetch(100)
     
     page=0
     limit=100
     users=[1]
     while users:
         logging.info("processing page "+str(page))
         users=User.all().fetch(limit,page*limit)
         for user in users:
             logging.info("processing user: "+user.nickname)
             articles=random.sample(all_articles,3)
             
             for article in articles:
                 if article.user != user:
                     article_cats=ArticleCategoryModel.all().filter("article =",article).fetch(100)
                     approval_count=0
                     for article_cat in article_cats:
                         userknowledges=UserKnowledgeModel.all().filter("user =",user).filter("category =",article_cat.category).fetch(1)
                         article_approval=ArticleApproveModel.all().filter("user =",user).filter("category =",article_cat.category).get()
                         if not article_approval:
                             article_approval=ArticleApproveModel(user=user,article=article,category=article_cat.category,score=0.01)
                         if userknowledges:
                             article_approval.score=userknowledges[0].score
                         article_approval.save()
                         approval_count=1
                     if article_approval > 0:
                         article.numapprovals=article.numapprovals+1
                         article.save();
         page=page+1
     
             
     return DevView(DevModel())
开发者ID:saidwords,项目名称:syytacit,代码行数:34,代码来源:BackupDevController.py


示例10: set_vote

def set_vote(quote_id, user_id, newvote, provider):
    if user_id is None:
        return

    if isinstance(user_id, unicode):
        auth_id = '%s:%s' % (provider, user_id)
        user = User.get_by_auth_id(auth_id)
    else:
        user = user_id

    email = user.email

    def txn():
        quote = Post.get_by_id(quote_id)
        vote = Vote.get_by_id(id=email, parent=quote.key)
        if vote is None:
            vote = Vote(id=email, parent=quote.key)
        if vote.vote == newvote:
            return
        quote.votesum = quote.votesum - vote.vote + newvote
        vote.vote = newvote

        quote.rank = "%020d|%s" % (
            long(quote.created * DAY_SCALE + quote.votesum),
            quote.creation_order
        )
        quote.put()
        vote.put()
        memcache.set("vote|" + email + "|" + str(quote_id), vote.vote)

    ndb.transaction(txn)
开发者ID:yashrajsingh,项目名称:projectyello-appengine-backend,代码行数:31,代码来源:modals.py


示例11: delete_orphaned_article_approvalsAction

 def delete_orphaned_article_approvalsAction(self):
     page=0
     limit=100
     records=[0]
     num_deleted=0
     total_records=0
     
     while records:
         records=ArticleApproveModel.all().fetch(limit,page*limit)
         for record in records:
             total_records=total_records+1
             if not record.parent():
                 record.delete()
                 num_deleted=num_deleted+1
                 
             else:
                 category=CategoryModel.get(record.category.key())
                 if not category:
                     record.delete()
                     num_deleted=num_deleted+1
                 else:
                     user=User.get(record.user.key())
                     if not user:
                         record.delete()
                         num_deleted=num_deleted+1
             
         page=page+1
     return DevView(DevModel())
开发者ID:saidwords,项目名称:syytacit,代码行数:28,代码来源:BackupDevController.py


示例12: printUser

def printUser():
    print "User List:"
    print 100 * '#'
    for user in User.query().fetch():
        for name in user._properties:
            print str(name) + ":" + str(getattr(user, name))
        print 100 * '#'
开发者ID:kp646576,项目名称:Convo,代码行数:7,代码来源:main.py


示例13: add_quote

def add_quote(title1, user_id, user_anon, provider, quote1=None, url1=None, image=None, _created=None):
    try:
        now = datetime.datetime.now()

        if isinstance(user_id, unicode):
            auth_id = '%s:%s' % (provider, user_id)
            user = User.get_by_auth_id(auth_id)
        else:
            user = user_id

        unique_user = _unique_user(user)
        if _created:
            created = _created
        else:
            created = (now - datetime.datetime(2008, 10, 1)).days

        q = Post(
                title=title1,
                quote=quote1,
                created=created,
                image=image,
                creator_anonymous=user_anon,
                creator=user.key,
                creation_order=now.isoformat()[:19] + "|" + unique_user,
                uri=url1
        )
        q.put()

        add_search_index(q.key.id(), title1, quote1, url1, image, user, user_anon)
        return q.key.id()

    except db.Error:
        return None
开发者ID:yashrajsingh,项目名称:projectyello-appengine-backend,代码行数:33,代码来源:modals.py


示例14: add_comment

def add_comment(user, user_anon, quote_id, text, provider):
    try:
        if user is None:
            return

        if isinstance(user, unicode):
            auth_id = '%s:%s' % (provider, user)
            user = User.get_by_auth_id(auth_id)
        else:
            user = user

        quote = Post.get_by_id(long(quote_id))
        comment = Comment(
                parent=quote.key,
                author_anonymous=user_anon,
                author=user.key,
                text=text
        )
        quote.comments += 1

        quote.put()
        comment.put()
        memcache.set("comment|" + user.email + "|" + str(quote_id), comment.text)

    except db.Error:
        return None
开发者ID:yashrajsingh,项目名称:projectyello-appengine-backend,代码行数:26,代码来源:modals.py


示例15: get

    def get(self, username, term, syllabus):
        # Deal with possible trailing slash
        if syllabus[-1] == '/':
            syllabus = syllabus[:-1]

        user = User.get_by_auth_id(username)
        terms = user.terms
        
        if terms:
            for t in terms:
                if t.url == term.upper():
                    syllabi = t.syllabi
                    for syl in syllabi:
                        if syl.info.url.lower() == syllabus.lower():
                            if not syl.isActive:
                                currentUser = None
                                if self.user:
                                    currentUser = ndb.Key(User, self.user['user_id']).get()
                                if not currentUser or username not in currentUser.auth_ids:
                                    self.abort(403)
                            self.render(t, syl)
                            return

        # Raise HTTP 404 error for syllabi that don't exist
        self.abort(404)
开发者ID:koszuta,项目名称:CS361,代码行数:25,代码来源:preview.py


示例16: login

	def login( self ):
		login = self.request.get( 'login', None );
		password = self.request.get( 'password', None );
		logging.info( "login=%s password=%s" % (login,password) );

		# パラメータチェック
		if (login is None) or (password is None):
			out = { "meta": functions.createMetaData( status="fail", code=400, cc_code=1000, message="login and password required") };
			logging.error( "login and password required" );
			self.response.out.write( json.encode(out) )
			return

		# ログインしようとしているユーザーがメアドを verify 済みかチェック
		auth_id = "own:"+ login
		m = self.user_model
		q = m.query( m.auth_ids==auth_id, m.verified==True )
		result = q.get();
		if result is None:
			out = { "meta": functions.createMetaData( status="fail", code=400, cc_code=1000, message="ユーザーが存在しないか、メールアドレス認証が完了していません") };
			logging.error( "ユーザーが存在しないか、メールアドレス認証が完了していません" );
			self.response.out.write( json.encode(out) )
			return

		user = None
		userInfo = self.auth.get_user_by_password( "own:"+ login, password, True, True, True )

		# 2013/01/06 以前のバージョンは頭に「own:」がついてなかったので、それにも対応。	
		if userInfo is None:
			logging.info( "2013/01/06 以前のバージョン方式でログインします" );
			userInfo = self.auth.get_user_by_password( login, password, True, True, True )

		if userInfo is None:
			# ログイン失敗
			logging.error( "Invalid email/username or password." );
			out = {
				"meta": functions.createMetaData(
					status="fail", code=401, cc_code=1000, message="Invalid email/username or password."
				),
			};
			self.response.out.write( json.encode(out) )
			return
		
		# ログイン成功
		user = User.get_by_id( userInfo["user_id"] )
		sessionId = self.serialize_user_token( auth_info=userInfo )
		out = {
			"meta": {
				"status": "ok",
				"code": 200,
				"method_name": "loginUser",
				"session_id": sessionId,
			},
			"response":{
				"users": [
					user.toDict( full=True ),
				],
			},
		};	
		self.response.out.write( json.encode(out) )
开发者ID:noughts,项目名称:openfish,代码行数:59,代码来源:users.py


示例17: get

 def get(self, _id=None):
     if self.user:
         q = User.gql('')
         response = [{'email': user.auth_ids[0], 'fullname': user.full_name} for user in q]
         self.response.headers.add_header('Content-Type', 'application/json')
         self.response.write(json.dumps(response))
     else:
         self.response.set_status(403)
开发者ID:carlitux,项目名称:test-gae,代码行数:8,代码来源:main.py


示例18: post

 def post(self,userid):
     print userid
     url = images.get_serving_url(self.get_uploads()[0].key())
     user = User.get_by_id(int(userid))
     print user
     user.img = url;
     user.put();
     self.response.write(resp.success())
开发者ID:jaredwindover,项目名称:SetScouter,代码行数:8,代码来源:Photo.py


示例19: get_group_users

	def get_group_users(cls, group):
		users = []
		entries = cls.query().filter(cls.group == group, cls.active == True).fetch()
		for entry in entries:
			stuff = entry.member
			user = User.get_by_id(entry.member.id())
			users.append(user)
		return users
开发者ID:StackMonkey,项目名称:site,代码行数:8,代码来源:models.py


示例20: calculate_user_knowledgeAction

 def calculate_user_knowledgeAction(self,nickname=None):
     self.checkEnv()
     if nickname:
         user=User.all().filter("nickname =",nickname).get()
     else:
         user=None
     KnowledgeLib.calculate_user_knowledge(user)
     return DevView(DevModel())
开发者ID:saidwords,项目名称:syytacit,代码行数:8,代码来源:BackupDevController.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python auth.get_auth函数代码示例发布时间:2022-05-26
下一篇:
Python webapp2.Router类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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