本文整理汇总了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))
示例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
示例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))
示例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))
示例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}))
示例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)
示例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
示例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 = []
示例9: tearDown
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def tearDown(self):
self.session.rollback()
Session.remove()
clear_all()
示例10: teardown_module
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def teardown_module():
from models import Base, Session
Session.remove()
示例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()
示例12: shutdown_session
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import remove [as 别名]
def shutdown_session(exception=None):
Session.remove()