本文整理汇总了Python中pycket.session.SessionManager类的典型用法代码示例。如果您正苦于以下问题:Python SessionManager类的具体用法?Python SessionManager怎么用?Python SessionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SessionManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: gets_default_value_if_provided_and_not_in_client
def gets_default_value_if_provided_and_not_in_client(self):
handler = StubHandler()
manager = SessionManager(handler)
value = manager.get('foo', 'Default')
self.assertEqual(value, 'Default')
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例2: retrieves_object_with_dict_key
def retrieves_object_with_dict_key(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('foo', 'bar')
self.assertEqual(manager['foo'], 'bar')
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例3: post
def post(self):
"""
"""
username = self.get_argument("username")
password = self.get_argument("password")
try:
connect_mongo.db.user.find_one({"username": username, "password": password})
if "username" == username & "password" == password:
session = SessionManager(self)
session.set('catId',username)
self.write("<script>alert('ورود موفقیت آمیز بود')</script>")
else:
self.render("Login.html")
# doc = connect_mongo.db.user.find_one({"username": username, "password": password})
# docc = doc["_id"]
# if docc > 0:
# session = SessionManager(self)
# session.set('loginid', docc)
# k = session.get('loginid')
# self.render("index.html")
except:
k = 1
self.render("Login.html", k=k)
开发者ID:LinkBook,项目名称:Tornado,代码行数:25,代码来源:application.py
示例4: sets_session_id_on_cookies
def sets_session_id_on_cookies(self):
test_case = self
class StubHandler(SessionMixin):
settings = {
'pycket': {
'engine': 'redis',
}
}
def get_secure_cookie(self, name):
test_case.assertEqual(name, 'PYCKET_ID')
self.cookie_set = True
return None
def set_secure_cookie(self, name, value, expires_days, expires):
test_case.assertEqual(name, 'PYCKET_ID')
test_case.assertIsInstance(value, str)
test_case.assertGreater(len(value), 0)
self.cookie_retrieved = True
handler = StubHandler()
session_manager = SessionManager(handler)
session_manager.set('some-object', 'Some object')
self.assertTrue(handler.cookie_retrieved)
self.assertTrue(handler.cookie_set)
开发者ID:Mondego,项目名称:pyreco,代码行数:27,代码来源:allPythonContent.py
示例5: get
def get(self):
session = SessionManager(self)
k = session.get('catId')
if k != None:
self.render("login.html")
else:
self.redirect('/indexihtml')
开发者ID:LinkBook,项目名称:Tornado,代码行数:7,代码来源:application.py
示例6: retrieves_session_with_same_data_as_saved
def retrieves_session_with_same_data_as_saved(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('some-object', {'foo': 'bar'})
self.assertEqual(manager.get('some-object')['foo'], 'bar')
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例7: gets_all_available_keys_from_session
def gets_all_available_keys_from_session(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('foo', 'FOO')
manager.set('bar', 'BAR')
self.assertListEqual(sorted(manager.keys()), sorted(['foo', 'bar']))
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py
示例8: deletes_item_using_command
def deletes_item_using_command(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('some-object', {'foo': 'bar'})
del manager['some-object']
self.assertIsNone(manager.get('some-object'))
开发者ID:Mondego,项目名称:pyreco,代码行数:9,代码来源:allPythonContent.py
示例9: still_retrieves_object_if_not_passed_from_expiration
def still_retrieves_object_if_not_passed_from_expiration(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('foo', 'bar')
time.sleep(1)
self.assertEqual(manager.get('foo'), 'bar')
开发者ID:Mondego,项目名称:pyreco,代码行数:9,代码来源:allPythonContent.py
示例10: saves_session_object_on_redis_with_same_session_id_as_cookie
def saves_session_object_on_redis_with_same_session_id_as_cookie(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('some-object', {'foo': 'bar'})
raw_session = self.client.get(handler.session_id)
session = pickle.loads(raw_session)
self.assertEqual(session['some-object']['foo'], 'bar')
开发者ID:Mondego,项目名称:pyreco,代码行数:10,代码来源:allPythonContent.py
示例11: cannot_retrieve_object_if_passed_from_expiration
def cannot_retrieve_object_if_passed_from_expiration(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.driver.EXPIRE_SECONDS = 1
manager.set('foo', 'bar')
time.sleep(manager.driver.EXPIRE_SECONDS + 1)
self.assertIsNone(manager.get('foo'))
开发者ID:Mondego,项目名称:pyreco,代码行数:10,代码来源:allPythonContent.py
示例12: get
def get(cls, handler, name):
session = SessionManager(handler)
Debug.dprint(text='name: ' + name, type='custom')
Debug.dprint(text='value: ' + str(session.get(name)), type='error')
# print "Session name is: " + name
# print "Do we have a session? " + str(session.get(name))
# if cls.exists(handler, name):
# print "There is a session"
# else:
# print "There is not any sessionn"
return session.get(name)
开发者ID:ehsansh84,项目名称:Customs,代码行数:11,代码来源:session2.py
示例13: iterates_without_method_over_keys
def iterates_without_method_over_keys(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('foo', 'FOO')
manager.set('bar', 'BAR')
iterations = 0
for key in manager:
self.assertTrue(key in manager)
iterations += 1
self.assertEqual(iterations, 2)
开发者ID:Mondego,项目名称:pyreco,代码行数:14,代码来源:allPythonContent.py
示例14: uses_custom_sessions_database_if_provided
def uses_custom_sessions_database_if_provided(self):
handler = StubHandler()
handler.settings = {
'pycket': {
'engine': 'redis',
'storage': {
'db_sessions': 10,
'db_notifications': 11,
}
},
}
manager = SessionManager(handler)
manager.set('foo', 'bar')
self.assertEqual(manager.driver.client.connection_pool._available_connections[0].db, 10)
开发者ID:Mondego,项目名称:pyreco,代码行数:14,代码来源:allPythonContent.py
示例15: get
def get(self):
sessionid = self.get_current_session()
session = SessionManager(self)
vh = VimHelper()
logging.debug("about to pull clusters using sessionid %s" % sessionid)
clusters = vh.GetClusters(sessionid)
f = TemplateFields()
f['username'] = self.get_current_user()
f['servername'] = session.get('server')
f['servertype'] = vh.ServerType(sessionid)
f['serverapi'] = vh.ApiVersion(sessionid)
f['clusterlist'] = clusters
self.render("listclusters.html", fields=f)
开发者ID:ytjohn,项目名称:rondurev,代码行数:14,代码来源:views.py
示例16: does_not_set_session_id_if_already_exists
def does_not_set_session_id_if_already_exists(self):
class StubHandler(SessionMixin):
settings = {
'pycket': {
'engine': 'redis',
}
}
def get_secure_cookie(self, name):
self.cookie_retrieved = True
return 'some-id'
handler = StubHandler()
manager = SessionManager(handler)
manager.set('some-object', 'Some object')
self.assertTrue(handler.cookie_retrieved)
开发者ID:Mondego,项目名称:pyreco,代码行数:17,代码来源:allPythonContent.py
示例17: sets_session_id_to_last_a_browser_session_as_default
def sets_session_id_to_last_a_browser_session_as_default(self):
test_case = self
class StubHandler(SessionMixin):
settings = {
'pycket': {
'engine': 'redis',
}
}
def get_secure_cookie(self, name):
return None
def set_secure_cookie(self, name, value, expires_days, expires):
test_case.assertIsNone(expires_days)
test_case.assertIsNone(expires)
handler = StubHandler()
manager = SessionManager(handler)
manager.set('some-object', 'Some object')
开发者ID:daqing15,项目名称:pycket,代码行数:19,代码来源:test_session.py
示例18: post
def post(self):
session = SessionManager(self)
# if session.get()
noun1 = self.get_argument('noun1')
noun2 = self.get_argument('noun2')
verb = self.get_argument('verb')
noun3 = self.get_argument('noun3')
us = self.get_current_user()
self.render('poem.html', roads=noun1, wood=noun2, made=verb,difference=noun3,user = us,ID=session.get('_id'),INFO=session.get('info'))
开发者ID:msajadi832,项目名称:Tornado,代码行数:10,代码来源:start.py
示例19: keeps_previous_items_when_setting_new_ones
def keeps_previous_items_when_setting_new_ones(self):
handler = StubHandler()
manager = SessionManager(handler)
manager.set('some-object', {'foo': 'bar'})
manager.set('some-object2', {'foo2': 'bar2'})
self.assertEqual(manager.get('some-object')['foo'], 'bar')
self.assertEqual(manager.get('some-object2')['foo2'], 'bar2')
开发者ID:Mondego,项目名称:pyreco,代码行数:9,代码来源:allPythonContent.py
示例20: uses_custom_expires_days_if_provided
def uses_custom_expires_days_if_provided(self):
test_case = self
class StubHandler(SessionMixin):
settings = {
'pycket': {
'engine': 'redis',
'cookies': {
'expires_days': 'St. Neversday',
}
},
}
def get_secure_cookie(self, name):
return None
def set_secure_cookie(self, *args, **kwargs):
test_case.assertEqual(kwargs['expires_days'], 'St. Neversday')
handler = StubHandler()
manager = SessionManager(handler)
manager.set('some-object', 'Some object')
开发者ID:daqing15,项目名称:pycket,代码行数:21,代码来源:test_session.py
注:本文中的pycket.session.SessionManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论