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


Python User.query方法代码示例

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


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

示例1: printUser

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
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,代码行数:9,代码来源:main.py

示例2: get

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
 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,代码行数:9,代码来源:main.py

示例3: send_rfps_to_subscribers

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
    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,代码行数:37,代码来源:email.py

示例4: send_reports

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
  def send_reports(self):
    queue = taskqueue.Queue('mail')
    keys = User.query().fetch(keys_only=True)

    for key in keys:
      task = taskqueue.Task(
        url='/worker/send_report',
        params={
          'key': key.urlsafe(),
        }
      )
      queue.add(task)
开发者ID:studyindenmark,项目名称:clerkster,代码行数:14,代码来源:cron.py

示例5: generate_reportAction

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
 def generate_reportAction(self):
     model={'num_comments':0,'num_articles':0,'num_users':0}
     # number of new comments in the last 24 hours
     model['num_comments']=Comments.all().filter("created >",(datetime.datetime.now()-datetime.timedelta(days=1))).count()
     # number of new articles in the last 24 hours
     model['num_articles']=ArticleModel.all().filter("updated >",(datetime.datetime.now()-datetime.timedelta(days=1))).count()
     # number of new users in the last 24 hours
     
     qry = User.query(User.created > datetime.datetime.now()-datetime.timedelta(days=1))
     model['num_users']=qry.count()
     
     mail.send_mail('[email protected]', '[email protected]', 'Daily Activity Report',str(model)) 
     
     return model
开发者ID:saidwords,项目名称:syytacit,代码行数:16,代码来源:CronController.py

示例6: sendMailCall

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
def sendMailCall(call):
    #TODO: fix template
    message = mail.EmailMessage(sender="MercatoLibero <[email protected]>",
                                subject="Nuova chiamata")
    users = User.query().fetch()
    to = ""
    for user in users:
        to += user.email + ";"
    message.to = to
    path = os.path.join(os.path.dirname(__file__), 'templates', 'mail_call.html')
    calls_open = Call.query(Call.status == "OPEN").fetch()
    open = [e.to_dict() for e in calls_open]
    params = dict(call=call.to_dict(), open=open)
    res = template.render(path, params)
    message.html = res
    message.send()
开发者ID:esseti,项目名称:fantacalcio-mercato-libero,代码行数:18,代码来源:cron.py

示例7: get

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
 def get(self):
     self.response.headers['Content-Type'] = 'application/json'
     print self.request.headers['Authorization']
     user = authenticate(self.request, int(self.request.get('userid')))
     if not user:
         self.response.write(resp.fail_auth())
     else:
         q = User.query()
         def convert(user):
             return {
                 'firstname' : user.firstname,
                 'lastname' : user.lastname,
                 'email' : user.auth_ids[0],
                 'id' : user.key.id(),
                 'img' : user.img
             }
         self.response.write(
             resp.success(
                 q.map(convert)
             )
         )
开发者ID:jaredwindover,项目名称:SetScouter,代码行数:23,代码来源:User.py

示例8: sendMailResult

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
def sendMailResult():
    # TODO: test this
    message = mail.EmailMessage(sender="MercatoLibero <[email protected]>",
                                subject="Risultati")
    users = User.query().fetch()
    to = ""
    for user in users:
        to += user.email + ";"
    message.to = to
    calls_open = Call.query(Call.status == "OPEN").fetch()
    status = Config.query().get()
    if not status:
        status = Config()
    status.is_open = True
    status.put()
    if len(calls_open) > 0:
        path = os.path.join(os.path.dirname(__file__), 'templates', 'mail_results.html')
        params = dict(open=[e.to_dict() for e in calls_open])
        res = template.render(path, params)
        for o in calls_open:
            o.status = "CLOSED"
            o.put()
        message.html = res
        message.send()
开发者ID:esseti,项目名称:fantacalcio-mercato-libero,代码行数:26,代码来源:cron.py

示例9: get

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
 def get(self):
     printUser()
     names = [str(getattr(user, 'auth_ids')[0]) for user in User.query().fetch()]
     names.sort()
     self.render_template('template.html', {'names': names})
开发者ID:kp646576,项目名称:Convo,代码行数:7,代码来源:main.py

示例10: getAllUsers

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
    def getAllUsers(self):
        return User.query()

        return users
开发者ID:felipecembranelli,项目名称:MerakiCaptivePortal,代码行数:6,代码来源:captivePortalHandler.py

示例11:

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
# webapp2 user store, how do you query it
from webapp2_extras.appengine.auth.models import User
myusers = User.query().fetch()
开发者ID:AK-1121,项目名称:code_extraction,代码行数:5,代码来源:python_14649.py

示例12: applyApprovals

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
 def applyApprovals(article,user1=None,approvals1=None,approve=True):
     x=0
     if not article.numapprovals:
         article.numapprovals=0
         
     if not article.r2:
         article.r2=0
     if not article.v2:
         article.v2=0
     
     if user1:
         users=[user1]
     else:
         users=User.query().fetch(200)
         
     for user in users:
         x=x+1
         if not user1:
             user.username=user.auth_ids[0]
         
         if approvals1:
             approvals=approvals1
         else:
             approvals=ArticleLib.getApprovals(article, user)
         if approve:
             article.numapprovals=article.numapprovals+1
             memcache.incr("n_approvals_"+str(article.key()),1,None,article.numapprovals-1)
             #foo=memcache.get("n_approvals_"+str(article.key()))
             #logging.info("incrememted napprovals to "+str(foo))
         article_cats=ArticleLib.getArticleCategories(article)
         
         for article_cat in article_cats:
             if approvals.has_key(article_cat.category.name):
                 if approve:
                     article_cat.v2=article_cat.v2+int(approvals[article_cat.category.name].score*100)
                 else:
                     article_cat.v2=article_cat.v2-int(approvals[article_cat.category.name].score*100)
             else:
                 if approve:
                     article_cat.v2=article_cat.v2+1
                 else:
                     article_cat.v2=article_cat.v2-1
         if article_cats:
             db.put(article_cats)
             
         impact=10+ArticleLib.calculate_impact(article, user.username)
         
         #logging.info("apply_impact to article: "+str(article.key()))
         #logging.info("apply impact = "+str(impact))    
         #foo=memcache.get("article_r2_"+str(article.key()))
         #logging.info("current rank ="+str(foo))
         
         if approve:
             #memcache.incr("article_r2_"+str(article.key()),impact)
             #velocity=memcache.get("article_v2_"+str(article.key()))
             #logging.info("current v2 = "+str(velocity))
             #logging.info("incrementing velocity +"+str(impact))
             if article.v2+impact < 9223372036854774807:
                 #memcache.incr("article_r2_"+str(article.key()),impact,None,article.r2+impact)
                 memcache.incr("article_v2_"+str(article.key()),impact,None,10)
                 article.v2=article.v2+impact
         else:
             #logging.info("descrementing velocity +"+str(impact))
             #memcache.decr("article_r2_"+str(article.key()),impact)
             if article.v2-impact >=0:
                 #memcache.decr("article_r2_"+str(article.key()),impact,None,article.r2-impact)
                 memcache.decr("article_v2_"+str(article.key()),impact,None,2)
                 article.v2=article.v2-impact
                 
     article.save()
     # clear cache
     #article_cats=ArticleLib.getArticleCategories(article,True,True)
      
     return True
开发者ID:saidwords,项目名称:syytacit,代码行数:76,代码来源:ArticleLib.py

示例13: get

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
    def get(self):
        if len(User.query().fetch()) == 0:
            bootstrap('test')

        self.render_response('admin/login.html')
开发者ID:Terhands,项目名称:saskdance,代码行数:7,代码来源:login.py

示例14: calculate_user_knowledge

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import query [as 别名]
 def calculate_user_knowledge(user=None,userpage=0,question=None,useranswer=None):
     
     from datetime import datetime
     today = datetime.today()
     
     #get the total number of questions for each category
     categorycount={}
     limit=100
     page=0
     questions=[0]
     cats={}
        
     total_records=0
     if user and user.username:
         if userpage==0:
             users=[user]
         else:
             users=[]
     else:
         users=User.query().fetch(200)
         
     for user in users:
         # get all the answers that the user has submitted
         page=0
         useranswers=[1]
         userknowledges = {}
        
         while useranswers:
             if question:
                 if useranswer:
                     if page==0:
                         useranswers=[useranswer]
                     else:
                         useranswers=[]
                 else:
                     useranswers=UserAnswerModel.all().filter("username =",user.username).filter("question =",question).fetch(limit,page*limit)
             else:
                 useranswers=UserAnswerModel.all().filter("username =",user.username).fetch(limit,page*limit)
     
             page=page+1
             for answer in useranswers:
                 if answer.iscorrect:
                     # if the user got the question correct and a long time passed since they answered this question, then give them a bonus score
                     # bonus is between 0 and 1
                     
                     if answer.iscorrect:
                         elapsed=answer.updated-answer.topa
                         if elapsed.total_seconds()<1:
                             topa=0.0;
                         else:
                             topa=0.0+1-((0.0+1)/elapsed.total_seconds())
                     else:
                         topa=0.0
                    
                     #calculate a delay ( how long it took the user to answer the question after seeing it on the ui)
                     delay=(0.0+1)/answer.delay
                     
                     # calculate a decay (the score will decrease if a question has not been answered in a long time )
                     elapsed=today-answer.updated
                     if elapsed.total_seconds()<1:
                         decay=0.0;
                     else:
                         decay=0.0+1-((0.0+1)/elapsed.total_seconds())
                     
                     point =1.0 + topa -delay-decay #maximum point value is 2
                     
                     """
                     logging.info(today)
                     logging.info(answer.topa)
                     logging.info(answer.updated)
                     
                     logging.info("topa="+str(topa))
                     logging.info("delay="+str(delay))
                     logging.info("decay="+str(decay))
                     """
                     #logging.info("point =1.0+  "+str(topa)+"-"+str(delay)+"-"+str(decay)+"="+str(point))
                     
                     
                 else:
                     point=0.0
                     
                 for cat_key in question.cats:
                     if userknowledges.has_key(cat_key):
                         userknowledges[cat_key]=userknowledges[cat_key]+point
                     else:
                         userknowledges[cat_key]=point
                         
                 #for catkey in userknowledges:
                 #    logging.info("changing score for "+str(catkey))
         
         for cat_key in userknowledges:
             category=CategoryModel.get(cat_key)
             userknowledge=UserKnowledgeModel.all().filter("username =",user.username).filter("category =",category).get()
             maxscore=KnowledgeLib.getMaxScore(category)
             if not userknowledge:
                 userknowledge=UserKnowledgeModel(username=user.username,category=category)
                 total_records=total_records+1
             userknowledge.score=userknowledges[cat_key] 
             userknowledge.pct=(0.0+userknowledge.score/maxscore)
             userknowledge.save()
#.........这里部分代码省略.........
开发者ID:saidwords,项目名称:syytacit,代码行数:103,代码来源:KnowledgeLib.py


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