本文整理汇总了Python中session.Session.set方法的典型用法代码示例。如果您正苦于以下问题:Python Session.set方法的具体用法?Python Session.set怎么用?Python Session.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类session.Session
的用法示例。
在下文中一共展示了Session.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_hangout
# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import set [as 别名]
def start_hangout(url, robot_sid):
"""Start google hangout in a selenium chromebrowser instance."""
#
# TODO if we have no network at this point, we fail, then never get a
# control port and can't close the selenium hangout
#
hangout = HangoutSession()
robot_session = RobotSession(robot_sid)
robot_session.set('hangout_control_port', hangout.driver.service.port)
hangout.join_hangout(url)
示例2: BasePage
# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import set [as 别名]
class BasePage(webapp.RequestHandler):
session = None #sessionを拡張
user = None #現在のユーザー
def initialize(self,request, response):
webapp.RequestHandler.initialize(self,request, response)
self.session = Session(request, response)
self.get_current_user()
def add_password(self, user, password):
self.auth_list.append({'user':user,'pass':password})
def render_json(self, result):
self.response.headers['Content-Type'] = 'text/javascript; charset=utf-8'
callback = re.sub("[^\w\d]","",self.request.get('callback'))
if callback:
self.response.out.write(callback + "(")
simplejson.dump(result,self.response.out, ensure_ascii=False)
if callback:
self.response.out.write(");")
def render(self,path,params):
if not params:
params = dict()
static_domain = ''
domain = ''
app_version = os.environ.get("CURRENT_VERSION_ID","")
domain = os.environ.get("SERVER_NAME","")
if domain != "www.caffein.tv":
app_version = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
params["app_version"] = app_version
params["user"] = self.user
#username
username = self.get_username()
params["username"] = username
path = os.path.join(os.path.dirname(__file__), path)
self.response.out.write(template.render(path, params))
def logout(self):
self.session.set("userkey","")
self.session.set("username","")
#セッションIDの振り直し(セキュリティ上重要!)
self.session.reset_key(self.request, self.response)
def get_userkey(self):
if self.user:
userkey = self.user.key().name()
else:
userkey = "session:" + self.session.get_key()
return userkey
def get_username(self):
username = self.session.get("username")
if not username and self.user:
username = self.user.username
if not username:
username = ""
return username
def get_current_user(self):
userkey = self.session.get("userkey")
self.user = None
if userkey:
person = memcache.get(userkey)
if not person:
person = Person.get_by_key_name(userkey)
memcache.set(userkey,person,20*24*60*60)
if person:
self.user = person
return True
def init_pagenation(self):
try:
return int(self.request.get('page',1))
except:
return 1
def make_pagenation(self,page,total):
prev = False
next = False
if page > 1:
prev = True
if int(page) < int(total):
next = True
#?以降のクエリー(URL)を作成
query_string = self.request.query_string
#.........这里部分代码省略.........