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


Python Session.remove方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
 def post(self):
     shot_id = self.get_argument('shot_id')
     username = self.get_argument('username')
     shot_upheld = self.get_argument('shot_upheld')
     claim = self.get_argument('claim', '')
     
     try:
         resolving_user = get_user(username=username)
         shot = get_shot(shot_id)
         game = get_game(shot.game_id)
         session = Session()
         
         mission = get_mission(game_id=game.id, assassin_id=shot.assassin_id, target_id=shot.target_id, completed_timestamp=None)
         
         if shot_upheld == 'True':
             if shot.target_id == resolving_user.id or resolving_user in game.game_masters:
                 shot.kill_upheld = True
                 game.mission_completed(mission, shot)
                 response_dict = get_response_dict(True)
         else:
             if shot.target_id == resolving_user.id:
                 dispute = Dispute(game.id, shot_id, claim)
                 session.add(dispute)
                 session.flush()
                 session.commit()
                 response_dict = get_response_dict(True)
             elif resolving_user in game.game_masters:
                 shot.kill_upheld = False
                 response_dict = get_response_dict(True)
     except Exception as e:
         session.rollback()
         response_dict = get_response_dict(False, e.message)
     finally:
         Session.remove()
         self.finish(simplejson.dumps(response_dict))
开发者ID:sosso,项目名称:Assassins-Server,代码行数:37,代码来源:game_action_handlers.py

示例2: _init_testdb

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def _init_testdb():
    from sqlalchemy import create_engine
    engine = create_engine("sqlite:///")
    engine.echo = True
    from models import Base, Session
    Session.remove()
    Base.metadata.create_all(bind=engine)
    Session.configure(bind=engine)
    return Session
开发者ID:aodag,项目名称:noseonalchemist,代码行数:11,代码来源:tests.py

示例3: post

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
 def post(self):
     game_id = self.get_argument('game_id')
     session = Session()
     try:
         game = get_game(game_id)
         game.start()
         response_dict = get_response_dict(True)
     except Exception as e:
         session.rollback()
         response_dict = get_response_dict(False, e.message)
     Session.remove()
     self.finish(simplejson.dumps(response_dict))
开发者ID:sosso,项目名称:Assassins-Server,代码行数:14,代码来源:game_master_handlers.py

示例4: get

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
 def get(self):
     username = self.get_argument('username')
     logger = logging.getLogger('ViewMission')
     session = Session()
     try:
         user = get_user(username=username)
         missions = session.query(Mission).filter_by(assassin_id=user.id, completed_timestamp=None)
         response = [x.get_api_response_dict() for x in missions]
     except Exception as e:
         response = get_response_dict(False, e.message)
         session.rollback()
     finally:
         Session.remove()
         self.finish(simplejson.dumps(response))
开发者ID:sosso,项目名称:Assassins-Server,代码行数:16,代码来源:game_action_handlers.py

示例5: post

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
 def post(self):
     username = self.get_argument('username')
     password = self.get_argument('password')
     session = Session()
     final_string = "ERROR"
     try:
         user = login(username=username, password=password)
         if user is not None:
             final_string = "SUCCESS"
             #TODO return their token
     except Exception:
         session.rollback()
     finally:
         Session.remove()
         self.finish(simplejson.dumps({'result':final_string}))
开发者ID:sosso,项目名称:Assassins-Server,代码行数:17,代码来源:dispute_handlers.py

示例6: process_game

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def process_game(game_id):
    game_url = base_game_details_url % game_id
    game_req = urllib2.Request(game_url, None, headers)
    try:
        game_result_html = urllib2.urlopen(game_req, None, 30).read()
        game_soup = BeautifulSoup(game_result_html)
        our_stats = game_soup.find('div', {"class":'yui-u first'})
        guys_who_played = our_stats.findAll('a', {"title":lambda x: x and x.startswith('View'), "class":None})
        session = Session()
        game = Game(match_id=game_id)
        session.add(game)
        session.flush()
        for teammate in guys_who_played:
            player = dbutils.get_or_create(session, Player, username=teammate.contents[0])
            game_played = GamePlayed(player.id, game.id)
            session.add(game_played)
        session.flush()
        session.commit()
        Session.remove()
        pass
    except Exception, e:
        print('Game request failed for %s' % game_id)
开发者ID:sosso,项目名称:eashl_stats2,代码行数:24,代码来源:main2.py

示例7: rank_fixer

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def rank_fixer():
    s = Session()
    time.clock()
    session = Session()
    if len(threads) != THREAD_COUNT:
        for i in range(THREAD_COUNT):
            t = ThreadCleaner(queue, s)
            t.setDaemon(True)
            t.start()
            threads.append(t)
    dirty_games = s.query(Game).filter(or_(Game.club_1_div_rank == -1, Game.club_2_div_rank == -1)).all()
    clubs_to_check = []
    for game in dirty_games:
        #        for club in [game.club_1, game.club_2]:
        #            if club not in clubs_to_check and club.should_update(ignore_time=True):
        #                queue.put(club.id)
        queue.put(game)
    queue.join()
    end = time.clock()
    print "Total time: %d" % end
    session.commit()
    Session.remove()
    pass
开发者ID:sosso,项目名称:eashl,代码行数:25,代码来源:datacleaning.py

示例8: open

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
                    os.makedirs("./uploads")
                if not os.path.exists("./uploads/%s" % username):
                    os.makedirs("./uploads/%s" % username)
                output_file = open("./uploads/" + username + "/" + final_filename, 'wb')
                output_file.write(file1['body'])
                item_completion.file_path = "uploads/" + username + "/" + final_filename

            session.add(item_completion)
            session.commit()
            final_string = "You have crossed item " + item_id + " off your bucket list!"
        except Exception, e:
            session.rollback()
            logger.exception(e)
            final_string = "Oops!  Something went wrong.  Please try again"
        finally:
            Session.remove()
            self.finish(final_string)


"""
username
"""
class GetCompletedItemsHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    def get(self):
        username = self.get_argument('username')

        session = Session()
        try:
            user = dbutils.get_or_create(session, User, username=username)
            item_array = []
开发者ID:sosso,项目名称:eashl_stats2,代码行数:33,代码来源:modelhandlers.py

示例9: tearDown

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
 def tearDown(self):
     self.session.rollback()
     Session.remove()
     clear_all()
开发者ID:sosso,项目名称:Assassins-Server,代码行数:6,代码来源:test_utils.py

示例10: teardown_module

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def teardown_module():
    from models import Base, Session
    Session.remove()
开发者ID:aodag,项目名称:noseonalchemist,代码行数:5,代码来源:tests2.py

示例11: teardown_module

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def teardown_module():
    from models import Base, Session
    Base.metadata.drop_all(bind=Session.bind)
    Session.remove()
开发者ID:aodag,项目名称:noseonalchemist,代码行数:6,代码来源:tests.py

示例12: shutdown_session

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def shutdown_session(exception=None):
    Session.remove()
开发者ID:danihodovic,项目名称:movlist-react-typescript,代码行数:4,代码来源:main.py


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