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


Python dbsession.query函数代码示例

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


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

示例1: cache_actions

def cache_actions():
    ''' Loads all of the actions from the database into memory for the scoreboard pages'''
    action_list = dbsession.query(models.Action).all()
    ws_manager = WebSocketManager.Instance()
    for action in action_list:
        team = dbsession.query(models.User).filter_by(id=action.user_id).first()
        score_update = ScoreUpdate(action.created.strftime("%d%H%M%S"), action.value, team.team_name)
        ws_manager.currentUpdates.append(score_update)
开发者ID:xaelek,项目名称:RootTheBox,代码行数:8,代码来源:__init__.py

示例2: by_ip_address

 def by_ip_address(cls, ip_addr):
     '''
     Returns a box object based on an ip address, supports both ipv4
     and ipv6
     '''
     db_ip = dbsession.query(IpAddress).filter(
         or_(IpAddress.v4 == ip_addr, IpAddress.v6 == ip_addr)
     ).first()
     if db_ip is not None:
         return dbsession.query(cls).filter_by(id=db_ip.box_id).first()
     else:
         return None
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:12,代码来源:Box.py

示例3: delivered

 def delivered(cls, user_id, uuid):
     notify = dbsession.query(cls).filter(
         and_(cls.event_uuid == uuid, cls.user_id == user_id)
     ).first()
     notify.viewed = True
     dbsession.add(notify)
     dbsession.flush()
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:7,代码来源:Notification.py

示例4: list

 def list(cls):
     ''' Returns a list of all categories in the database '''
     categories = dbsession.query(cls).all()
     catlist = []
     for cat in categories:
         catlist.append(cat.category)
     return json.dumps(catlist)
开发者ID:moloch--,项目名称:RootTheBox,代码行数:7,代码来源:Category.py

示例5: team_name

 def team_name(self):
     """ Return a list with all groups names the user is a member of """
     if self.team_id == None:
         return None
     else:
         team = dbsession.query(Team).filter_by(id=self.team_id).first() #@UndefinedVariable
         return team.team_name
开发者ID:xaelek,项目名称:RootTheBox,代码行数:7,代码来源:User.py

示例6: by_ip_address

 def by_ip_address(cls, ip_addr):
     '''
     Returns a box object based on an ip address, supports both ipv4
     and ipv6
     '''
     ip = dbsession.query(IpAddress).by_address(ip_addr).first()
     return ip.box if ip is not None else None
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:7,代码来源:Box.py

示例7: delivered

 def delivered(cls, user_id, uuid):
     notify = dbsession.query(cls).filter(
         and_(cls.event_uuid == uuid, cls.user_id == user_id)
     ).first()
     if notify is not None:
         notify.viewed = True
         dbsession.add(notify)
         dbsession.commit()
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:8,代码来源:Notification.py

示例8: score

 def score(self):
     ''' Returns user's current score from cache, or re-calculates if expired '''
     if self.dirty:
         actions = dbsession.query(Action).filter_by(user_id=self.id).all() #@UndefinedVariable
         self.score_cache = sum(actions)
         self.dirty = False
         dbsession.add(self)
         dbsession.flush()
     return self.score_cache
开发者ID:xaelek,项目名称:RootTheBox,代码行数:9,代码来源:User.py

示例9: get_monster

 def get_monster(cls, user):
     ''' Based on the users quest and level this will choose an appropriate monster '''
     quest = Quest.by_id(user.quest_level)
     #If we are still on quests
     if quest != None:
         #Get all valid monsters
         all = dbsession.query(cls).filter(cls.level<=quest.max_monster_level).filter(cls.level>=quest.min_monster_level).all()
         return choice(all)
     return choice(cls.get_all())
开发者ID:hathcox,项目名称:Arthur,代码行数:9,代码来源:Monster.py

示例10: get_current_user

def get_current_user(self):
    """
    Return the request's user object.
    can be called using BaseHandler self.get_current_user() or
    by get_current_user(request_handler_instance)    
    """
    # loads the cookie and query the database to compare passwords.
    # if password was changed/deleted (in the server side) then treats as unauthed
    auth = loads(self.get_secure_cookie('auth') or '""')
    if auth:
        user = dbsession.query(User).get(auth['id'])
        if user and user.password[0:8] == auth['password']: return user
开发者ID:shinriyo,项目名称:teaspoon3,代码行数:12,代码来源:controller.py

示例11: by_username

 def by_username(cls, user_name):
     """ Return the user object whose user name is 'user_name' """
     return dbsession.query(cls).filter_by(username=unicode(user_name)).first()
开发者ID:gruns,项目名称:The-Planetary-Assault-System,代码行数:3,代码来源:User.py

示例12: all

 def all(cls):
     """ Return all non-admin user objects """
     return dbsession.query(cls).all()
开发者ID:gruns,项目名称:The-Planetary-Assault-System,代码行数:3,代码来源:User.py

示例13: get_approved

 def get_approved(cls):
     """ Return all approved user objects """
     return dbsession.query(cls).filter_by(approved=True).all()
开发者ID:gruns,项目名称:The-Planetary-Assault-System,代码行数:3,代码来源:User.py

示例14: get_unapproved

 def get_unapproved(cls):
     """ Return all unapproved user objects """
     return dbsession.query(cls).filter_by(approved=False).all()
开发者ID:gruns,项目名称:The-Planetary-Assault-System,代码行数:3,代码来源:User.py

示例15: all

 def all(cls):
     ''' Returns a list of all objects in the database '''
     return dbsession.query(cls).all()
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:3,代码来源:Snapshot.py


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