本文整理汇总了Python中model.Session类的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: wrapper
def wrapper(self, *args, **kwargs):
#Get the session parameters
auth_id = self.request.cookies.get('auth_id', '')
session_id = self.request.cookies.get('session_id', '')
#Check the db for the session
session = Session.GetSession(session_id, auth_id)
if session is None:
session = Session()
session.session_id = Session.MakeId()
session.auth_token = Session.MakeId()
session.put()
# Attach the session to the method
self.SessionObj = session
#Call the handler.
result = method(self, *args, **kwargs)
self.response.headers.add_header('Set-Cookie', 'auth_id=%s; path=/; HttpOnly' % str(session.auth_token))
self.response.headers.add_header('Set-Cookie', 'session_id=%s; path=/; HttpOnly' % str(session.session_id))
return result
开发者ID:PaulKinlan,项目名称:BuzzInOutDemo,代码行数:25,代码来源:webdecorators.py
示例2: on_message
def on_message(msg, server):
text = msg.get("text", "")
match = re.findall(r"!status( .*)?", text)
if not match: return
session = Session()
try:
realm = session.query(Realm).filter(Realm.name == wowconfig["realm"]).one()
status = u"Currently *{0}* is ".format(realm.name)
if realm.online:
status += "online (last check: {0})".format(
humanize.naturaltime(realm.lastchecked)
)
status += "\n\n*Battleground status*:\n```"
for area in realm.areas:
status += "{0} : {1} controlled : {2} : next in {3}\n".format(
area.name,
area.faction,
area.status,
humanize.naturaldelta(area.next),
)
status += "```"
else:
status += "offline (last check: {0}, last seen: {1})".format(
humanize.naturaltime(realm.lastchecked),
humanize.naturaltime(realm.lastseen)
)
return status
except NoResultFound:
return u"No status known on *{0}*".format(wowconfig["realm"])
开发者ID:Michaeljmeyer3,项目名称:slackcraft,代码行数:34,代码来源:status.py
示例3: main_page
def main_page():
s = Session()
books = s.query(Book).all()
authors = s.query(Author).all()
s.close()
return render_template('beta.html', books=books, authors=authors)
开发者ID:Azurin,项目名称:beta,代码行数:7,代码来源:controller.py
示例4: do_command
def do_command (task_id) :
try :
task_res = get_task_by_id(task_id)
if task_res["status"] != 0 :
return {"status":-1 , "val":None}
task = task_res["val"]["task"]
group_id = script_group = task_res["val"]["script_group"].id
server_group = task_res["val"]["server_group"]
scripts = get_scripts_by_group_id(group_id)["val"]
script_list = []
for script in scripts :
script_list.append(str(script.location))
server_list = []
for server in server_group.servers :
server_list.append(server.dump())
if script_list == [] or server_list == [] :
return {"status":-1 , "val":None}
task_to_do = {"scripts":script_list , "servers":server_list}
success_array , key_code_list = upload_remotefile.do_task(task_to_do)
session = Session()
taskStatus = session.query(TaskStatus).filter(TaskStatus.task_id == task_id).first()
if taskStatus == None :
taskStatus = TaskStatus(task_id , json.dumps(success_array) , json.dumps(key_code_list))
taskStatus_id = taskStatus.save_return_id(session)
else :
taskStatus.success_array = json.dumps(success_array)
taskStatus.key_code_list = json.dumps(key_code_list)
taskStatus_id = taskStatus.id
taskStatus.save(session)
session.close()
return {"status":0 , "val":taskStatus_id}
except Exception , msginfo :
return {"status":-1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:33,代码来源:helper.py
示例5: syncSeason
def syncSeason(self, serie, season):
qry = Session.query(Serie).filter_by(path=serie)
if qry.count() == 0:
raise Exception("No serie linked to %s/%s" % (serie, saison))
serie = qry.one()
path = season
num = getSeasonNumFromFoldername(season)
if num is None:
raise Exception("This is not a season (%s)" % season)
season = filter(lambda season: season.num == num, serie.seasons)
if len(season) == 0:
season = Season(num=num, path=path)
Session.add(season)
serie.seasons.append(season)
else:
assert 1 == len(season)
season = season[0]
season.num = num
season.path = path
episodes = glob(os.path.join(self.basepath, serie.path, season.path, "*"))
episodes = filter(lambda episode: os.path.isfile(episode), episodes)
for episode in [os.path.basename(e) for e in episodes]:
try:
self.syncEpisode(serie.path, season.path, episode)
except:
pass
开发者ID:PiTiLeZarD,项目名称:BetaSeries-Scripts,代码行数:31,代码来源:filesystem.py
示例6: initialize_device
def initialize_device():
"""
Set up the Device info into the database.
By this time, the HardwareDefinition and SoftwareDefinition
entries must be entered.
"""
session = Session()
hd = session.query(HardwareDefinition).one()
sd = session.query(SoftwareDefinition).one()
device = Device(id=hd.serial_number,
interior_sensor=hd.interior_sensor,
exterior_sensor=hd.exterior_sensor)
device.hardware_version = hd.hardware_version
device.software_version = sd.software_version
device.database_service = True # database always set to True
device.device_service = sd.device_service
device.grainbin_service = sd.grainbin_service
session.add(device)
# set grainbin info
if sd.grainbin_service:
grainbins = initialize_grainbin(device.id, hd.grainbin_reader_count)
device.grainbin_count = len(grainbins)
session.add_all(grainbins)
session.commit()
session.close()
return
开发者ID:nstoik,项目名称:farm_device,代码行数:31,代码来源:db_manage.py
示例7: LogHandlerTests
class LogHandlerTests(reader.LogHandler):
def __init__(self):
self.session = Session()
self.tests = {(item.test, item.subtest) for item in self.session.query(Test)}
self.new_tests = []
def _insert_test(self, test, subtest):
if (test, subtest) not in self.tests:
test_obj = {"test": test,
"subtest": subtest}
self.new_tests.append(test_obj)
self.tests.add((test, subtest))
def test_status(self, data):
test = self._insert_test(data["test"], data["subtest"])
def test_end(self, data):
self._insert_test(data["test"], None)
sys.stdout.write("-")
sys.stdout.flush()
def suite_end(self, data):
self.session.bulk_insert_mappings(Test, self.new_tests)
self.session.commit()
sys.stdout.write(" committing\n")
开发者ID:jgraham,项目名称:wptreport,代码行数:25,代码来源:dbhandler.py
示例8: main_page
def main_page():
s = Session()
meals = s.query(Meal).all()
products = s.query(Product).all()
s.close()
return render_template('beta.html', meals=meals, products=products)
开发者ID:Azurin,项目名称:kk,代码行数:7,代码来源:controller.py
示例9: draw_table
def draw_table(self):
s = Session()
self.orders = s.query(Order).all()
s.close()
self.ui.orders_table.clear()
self.ui.orders_table.setRowCount(1)
self.ui.orders_table.setColumnCount(5)
self.ui.orders_table.setHorizontalHeaderLabels([QString.fromUtf8('Номер'), QString.fromUtf8('Поломка'),
QString.fromUtf8('Дата приемки'), QString.fromUtf8('Клиент'),
QString.fromUtf8('Статус')])
#self.ui.orders_table.resizeColumnsToContents()
for order in self.orders:
data = []
data.append(str(order.id))
data.append(QString.fromUtf8(order.device))
data.append(str(order.get_ordered_date()))
data.append(QString.fromUtf8(order.get_client().get_fio()))
data.append(QString.fromUtf8(order.get_status(1).to_string()))
for i in range(0,5):
tableitem = QTableWidgetItem()
tableitem.setText(data[i])
tableitem.font = QFont("Arial", 10)
tableitem.font.setBold(True)
tableitem.textcolor = QColor("black")
self.ui.orders_table.setItem(self.ui.orders_table.rowCount() - 1,i,tableitem)
self.ui.orders_table.setRowCount(self.ui.orders_table.rowCount()+1)
self.ui.orders_table.resizeColumnsToContents()
开发者ID:frolova,项目名称:sc,代码行数:28,代码来源:OrdersWidget.py
示例10: make_account
def make_account(username, password):
session = Session()
a = Account(username, password)
session.add(a)
bot = MBotData("testerbot", 0, 0, )
session.commit()
开发者ID:shmup,项目名称:another-python-mud,代码行数:7,代码来源:account.py
示例11: update_position
def update_position(group_id , json_str) :
try :
session = Session()
position_list = json_str.split('|')
position_list.remove(position_list[len(position_list)-1])
for i in range(len(position_list)) :
position_list[i] = int(str(position_list[i]))
sorted_script = session.query(Sorted_Script).filter(Sorted_Script.group_id == group_id).first()
sorted_array = json.loads(sorted_script.sorted_array)
check = True
for item in position_list :
if item not in sorted_array :
check = False
break
if len(position_list) != len(sorted_array) :
check = False
if check == True :
sorted_script.sorted_array = json.dumps(position_list)
sorted_script.save(session)
return {"status":0 , "val":None}
else :
return {"status":-1 , "val":None}
except Exception , msginfo :
return {"status":-1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:25,代码来源:helper.py
示例12: delete
def delete(self, sessionid):
s = Session()
with s.transaction:
session = s.query(CoachingSession).get(sessionid)
if session:
s.delete(session)
else:
self.response.set_status(404)
开发者ID:brotchie,项目名称:redsapp,代码行数:8,代码来源:web.py
示例13: get_script_by_id
def get_script_by_id(script_id) :
try :
session = Session()
script = session.query(Script).filter(Script.id == script_id).first()
if script == None :
return {"status":-1 , "val":None}
return {"status":0 , "val":script}
except Exception , msginfo :
return {"status": -1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:9,代码来源:helper.py
示例14: login
def login(self):
s = Session()
res = s.query(Staff).filter_by(login=unicode(self.ui.login.text()),
passwd=unicode(self.ui.password.text())).all()
if len(res):
self.mv = MainWindow(res[0])
self.mv.show()
self.close()
s.close()
开发者ID:frolova,项目名称:sc,代码行数:9,代码来源:LoginWindow.py
示例15: get_service_group_by_id
def get_service_group_by_id(group_id) :
try :
session = Session()
group_list = session.query(ServerGroup).all()
if group_list == None or len(group_list) == 0 :
return {"status":-1 , "val":None}
return {"status":0 , "val":group_list}
except Exception , msginfo :
return {"status":-1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:9,代码来源:helper.py
示例16: get_stored_range
def get_stored_range(x_min, x_max, y_min, y_max):
session = Session()
value = session.query(DataMap).filter(and_(DataMap.x >= x_min, DataMap.x <= x_max, \
DataMap.y >= y_min, DataMap.y <= y_max)).all()
ret_val = {}
for tile in value:
ret_val[(tile.x, tile.y)] = tile.value
return ret_val
开发者ID:shmup,项目名称:another-python-mud,代码行数:9,代码来源:data_map.py
示例17: get_server_by_id
def get_server_by_id(server_id) :
try :
session = Session()
server = session.query(Server).filter(Server.id == server_id).first()
if server == None :
return {"status":-1 , "val":None}
return {"status":0 , "val":server}
except Exception , msginfo :
return {"status": -1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:9,代码来源:helper.py
示例18: get_script_group_list
def get_script_group_list() :
try :
session = Session()
group_list = session.query(ScriptGroup).all()
if group_list == None or len(group_list) == 0 :
return {"status":-1 , "val":None}
return {"status":0 , "val":group_list}
except Exception , msginfo :
return {"status": -1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:9,代码来源:helper.py
示例19: get_server_group_by_id
def get_server_group_by_id(group_id) :
try :
session = Session()
group = session.query(ServerGroup).filter(ServerGroup.id == group_id).first()
group.servers = group.servers
if group == None :
return {"status":-1 , "val":None}
return {"status":0 , "val":group}
except Exception , msginfo :
return {"status": -1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:10,代码来源:helper.py
示例20: draw_client_combo
def draw_client_combo(self):
combo = self.ui.client
s = Session()
clients = s.query(Client).all()
s.close()
combo.clear()
for cl in clients:
combo.addItem('%i %s %s'%(cl.id, cl.surname, cl.name))
#QObject.connect(self.ui.manufacter_combo, SIGNAL("currentIndexChanged(int)"), self.setManufacter)
#self.setManufacter(0)
开发者ID:frolova,项目名称:sc,代码行数:10,代码来源:AddOrderWidget.py
注:本文中的model.Session类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论