本文整理汇总了Python中webapp2_extras.sessions.get_store函数的典型用法代码示例。如果您正苦于以下问题:Python get_store函数的具体用法?Python get_store怎么用?Python get_store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_store函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dispatch
def dispatch(self):
# by default, the session ID is set in the Cookie header, but we can't rely on
# cookies because of 3rd party cookie restrictions. so we pass the session ID through GET
# parameters and unset the cookie before the response is sent
self.session_id = self.request.get("SESSION")
if self.session_id:
self.request.cookies["session"] = self.session_id
self.session_store = sessions.get_store(request=self.request)
self.session # touch the object to guarantee its instantiation
else:
self.session_store = sessions.get_store(request=self.request)
try:
# there was no session yet, so we assume a valid signed request from Speakap
# if the signed request is not valid, an exception is raised
signed_params = dict(self.request.params)
speakap_api.validate_signature(signed_params)
# we copy all parameters from the signed request to a new user session (the session
# is created implicitly), so the params are available on follow-up requests
for key in signed_params:
self.session[key] = signed_params[key]
self.session_store.save_sessions(self.response)
# ugly method to get the session ID from the Set-Cookie header
self.session_id = self.response.headers["Set-Cookie"].split(";")[0].split("=", 2)[1]
except speakap.SignatureValidationError, exception:
print exception
self.show_auth_error()
return
开发者ID:SpeakapBV,项目名称:ExampleApp,代码行数:30,代码来源:example-app.py
示例2: process
def process(self, resource_id, *args, **kwargs):
from voluptuous import Schema
from google.appengine.api import namespace_manager
namespace_manager.set_namespace('_x_')
session_store = sessions.get_store(request=self.request)
session = session_store.get_session()
if not 'u' in session:
self.about(403)
return
obj = json.loads(self.request.body)
schema = Schema(self.schema, extra=True)
try:
obj = schema(obj)
except:
logging.exception('validation failed')
session_store = sessions.get_store()
session = session_store.get_session()
school_key = ndb.Key(urlsafe = session.get('s'))
obj['school'] = school_key
entity = self.entity.from_dict(obj)
entity.put()
self.write_json_response(entity.to_dict())
开发者ID:SOSbeacon,项目名称:SchoolBeacon-GAE,代码行数:32,代码来源:__init__.py
示例3: dispatch
def dispatch(self):
self.session_store = sessions.get_store(factory=sessions.SessionStore, key='webapp2_extras.sessions.SessionStore', request=self.request)
self.session_flash = sessions.get_store(factory=sessions.SessionDict, key='webapp2_extras.sessions.SessionDict', request=self.request)
try:
RequestHandler.dispatch(self)
finally:
self.session_store.save_sessions(self.response)
开发者ID:PeithVergil,项目名称:dagkot,代码行数:8,代码来源:base.py
示例4: post_logout
def post_logout(self):
self.auth.unset_session()
# User is logged out, let's try redirecting to login page
#try:
# self.redirect(self.default_uri)
#except (AttributeError, KeyError), e:
# return "User is logged out"
#finally:
self.redirect(self.default_uri)
sessions.get_store(request=self.request).save_sessions(self.response)
开发者ID:Diddit,项目名称:diddit,代码行数:11,代码来源:gaut.py
示例5: __init__
def __init__(self, request, response):
""" constructor """
main.log('Initializing base page.')
self.initialize(request, response)
self.session_store = sessions.get_store(request=request)
self._initialize_login()
开发者ID:guildenstern70,项目名称:facelogin,代码行数:7,代码来源:pages.py
示例6: session_store
def session_store(self):
try:
store = sessions.get_store(request=self.request)
return store
except Exception as e:
print "Session_store"
print e
开发者ID:tilau2328,项目名称:RESTaurant-Manager,代码行数:7,代码来源:portal.py
示例7: dispatch
def dispatch(self):
""" 需要管理員身份才可執行 """
self.session_store = sessions.get_store(request=self.request)
user = users.get_current_user()
if user is not None and users.is_current_user_admin() is False:
from application.database import DBAdministrator
from google.appengine.ext import db
ds = db.Query(DBAdministrator)
ds.filter('email =', str(user.email()))
record = ds.get()
if record is not None and record.is_enable == True :
self.session["administrator_email"] = record.email
if self.session["administrator_email"] is None or self.session["administrator_email"] == "":
self.login_message = u'此帳號權限不足,請使用別的帳號 <a href="' + users.create_login_url("/admin") + u'" class="register">重新登入</a>'
self.e403()
return
else:
if user is not None:
self.session["administrator_email"] = user.email()
if self.session.has_key("administrator_email") is False:
self.session["administrator_email"] = u""
if self.session["administrator_email"] is u"":
self.login_message = u"請先登入系統,您也可以使用 Google 帳號登入"
self.e403()
return
self.administrator_email = self.session["administrator_email"]
self.size = Pagination.get_int_param(self,"size",50)
self.page = Pagination.get_int_param(self,"page",1)
self.page_now = self.page
super(BaseHandler, self).dispatch()
self.session_store.save_sessions(self.response)
开发者ID:cwen0708,项目名称:gae-biofa,代码行数:33,代码来源:__init__.py
示例8: dispatch
def dispatch(self):
# Get a session store for this request.
self.session_store = sessions.get_store(request=self.request)
self.request.mobile = False
try:
if self.request.headers.has_key("X-OperaMini-Features"):
#Then it's running opera mini. 'Nuff said.
#Reference from:
# http://dev.opera.com/articles/view/opera-mini-request-headers/
self.request.mobile = True
if self.request.headers.has_key("Accept"):
s = self.request.headers["Accept"].lower()
if 'application/vnd.wap.xhtml+xml' in s:
# Then it's a wap browser
self.request.mobile = True
if self.request.headers.has_key("User-Agent"):
# This takes the most processing. Surprisingly enough, when I
# Experimented on my own machine, this was the most efficient
# algorithm. Certainly more so than regexes.
# Also, Caching didn't help much, with real-world caches.
s = self.request.headers["User-Agent"].lower()
for ua in search_strings:
if ua in s:
self.request.mobile = True
#Otherwise it's not a mobile
webapp2.RequestHandler.dispatch(self)
finally:
# Save all sessions.
self.session_store.save_sessions(self.response)
开发者ID:jsalcedo09,项目名称:webengine,代码行数:31,代码来源:handlers.py
示例9: post
def post(self):
username = self.request.get('username')
password = self.request.get('password')
try:
database = gdbm.open('database.gdbm','cf')
except:
time.sleep(0.1)
database = gdbm.open('database.gdbm','cf')
if ('usr'+username).encode('ascii','ignore') in database:
auth_info = json.loads(
database[('usr'+username).encode('ascii','ignore')]
)
if auth_info['password'] == password:
session_store = sessions.get_store(request=self.request)
session = session_store.get_session()
session['key'] = auth_info['key']
session['username'] = username
session_store.save_sessions(self.response)
database.close()
self.redirect('/jj70/abstracts')
else:
database.close()
self.redirect('/jj70/login')
else:
database.close()
self.redirect('/jj70/login')
开发者ID:guillemborrell,项目名称:jj70,代码行数:29,代码来源:main.py
示例10: dispatch
def dispatch(self):
self.session_store = sessions.get_store(request=self.request)
try:
super(BaseApiHandler, self).dispatch()
finally:
self.session_store.save_sessions(self.response)
开发者ID:jwalton,项目名称:xmppvoicemail,代码行数:7,代码来源:main.py
示例11: dispatch
def dispatch(self):
self.session_store = sessions.get_store(request = self.request)
try:
webapp2.RequestHandler.dispatch(self)
finally:
self.session_store.save_sessions(self.response)
开发者ID:koszuta,项目名称:CS361,代码行数:7,代码来源:basehandler.py
示例12: dispatch
def dispatch(self):
log.debug('starting dispatch')
# Get a session store for this request.
self.session_store = sessions.get_store(request=self.request)
self.request.registry['session'] = self.session
try:
# Dispatch the request.
webapp2.RequestHandler.dispatch(self)
except suds.WebFault as e:
if e.message == authentication_failed:
self.response.write(json.dumps({'logged_in': False}))
self.response.status = 401
elif e.message == access_denied:
self.response.write(json.dumps({'logged_in': True,
'message': "Access Denied"}))
self.response.status = 403
else:
self.response.write(json.dumps({
'logged_in': True,
'message': 'WebFault: {}. See logs'.format(e.message)}))
self.response.status = 500
log.exception('Got an unhandled WebFault. Sent a 500 message.')
finally:
# Save all sessions.
self.session_store.save_sessions(self.response)
log.debug('ending dispatch')
开发者ID:digidotcom,项目名称:map-idigi,代码行数:27,代码来源:base.py
示例13: dispatch
def dispatch(self):
self.session_store = sessions.get_store(request=self.request)
try:
webapp2.RequestHandler.dispatch(self)
except Exception, e:
logging.error(e)
self.redirect("/logout/")
开发者ID:roofcat,项目名称:etracking,代码行数:7,代码来源:app_controller.py
示例14: dispatch
def dispatch(self):
self.user = User()
'''
Method dispatcher for wrapping method calls within the context of 'self'
Any variables created here are given to the method handlers as 'self'
:return:
'''
self.session_store = sessions.get_store(request=self.request)
try:
# call method handler
results = _webapp.RequestHandler.dispatch(self)
if results is True:
self.response.set_status(200)
elif results is False:
self.response.set_status(501)
elif results is dict or results is list:
# nah -- it's another type, it's JSON
self.response.content_type = "application/json"
self.response.out.write(json.dumps(results))
elif results is None:
self.response.set_status(200)
logging.info("null response from handler")
else:
self.response.out.write(results)
finally:
# store session
self.session_store.save_sessions(self.response)
开发者ID:markferry-wf,项目名称:whiterabbit-boilerplate,代码行数:31,代码来源:app.py
示例15: dispatch
def dispatch(self):
"""Wraps the dispatch method to add session handling."""
self.session_store = sessions.get_store(request=self.request)
self.decorator = decorator
# Add the user's credentials to the decorator if we have them.
if self.me:
self.decorator.credentials = self.decorator._storage_class(
model=self.decorator._credentials_class,
key_name='user:{}'.format(self.me.user_id()),
property_name=self.decorator._credentials_property_name).get()
else:
# Create a session ID for the session if it does not have one already.
# This is used to create an opaque string that can be passed to the OAuth2
# authentication server via the 'state' parameter.
if not self.session.get('sid'):
self.session['sid'] = security.generate_random_string(entropy=128)
# Store the state for the session user in a parameter on the flow.
# We only need to do this if we're not logged in.
self.decorator._create_flow(self)
session_user = SessionUser(self.session['sid'])
logging.info(self.decorator.flow.params)
self.decorator.flow.params['state'] = appengine._build_state_value(
self, session_user)
try:
webapp2.RequestHandler.dispatch(self)
finally:
self.session_store.save_sessions(self.response)
开发者ID:grow,项目名称:webreview,代码行数:30,代码来源:handlers.py
示例16: dispatch
def dispatch(self):
# get a session store for this request
self.session_store = sessions.get_store(request=self.request)
# always check CSRF if this is a post unless explicitly disabled
if self.request.method == 'POST' and not self.SKIP_CSRF:
if not self.checkCSRF():
return self.renderError(412)
if hasattr(self, "before"):
try:
self.before(*self.request.route_args, **self.request.route_kwargs)
except Exception as e:
self.handle_exception(e, False)
# only run the regular action if there isn't already an error or redirect
if self.response.status_int == 200:
webapp2.RequestHandler.dispatch(self)
if hasattr(self, "after"):
try:
self.after(*self.request.route_args, **self.request.route_kwargs)
except Exception as e:
self.handle_exception(e, False)
# save all sessions
self.session_store.save_sessions(self.response)
开发者ID:bdoms,项目名称:gae_scaffold,代码行数:27,代码来源:base.py
示例17: dispatch
def dispatch(self):
# Get a session store for this request.
self.session_store = sessions.get_store(request=self.request)
try: # Dispatch the request.
webapp2.RequestHandler.dispatch(self)
finally: # Save all sessions.
self.session_store.save_sessions(self.response)
开发者ID:EnerNOC,项目名称:remoht.us,代码行数:7,代码来源:__init__.py
示例18: get
def get(self):
session_store = sessions.get_store(request=self.request)
session = session_store.get_session()
username = session.get('username')
key = session.get('key')
try:
database = gdbm.open('database.gdbm','cf')
except:
time.sleep(1.0)
database = gdbm.open('database.gdbm','cf')
if username:
if ('usr'+username).encode('ascii','ignore') in database:
auth_info = json.loads(
database[('usr'+username).encode('ascii','ignore')]
)
if auth_info['key'] == key:
template_values = {'auth':auth_info}
template = JINJA_ENVIRONMENT.get_template('ko.html')
database.close()
self.response.write(template.render(template_values))
else:
database.close()
self.redirect('/jj70/login')
else:
database.close()
self.redirect('/jj70/login')
else:
database.close()
self.redirect('/jj70/login')
开发者ID:guillemborrell,项目名称:jj70,代码行数:35,代码来源:main.py
示例19: get
def get(self, *args, **kwargs):
session_store = sessions.get_store()
session = session_store.get_session()
if session:
# TODO: Is there a better way to do this?
for key in session.keys():
del session[key]
federated_identity = OPENID_ENDPOINT_GOOGLE
token = self.request.get('tk')
if token:
session['tk'] = token
session_store.save_sessions(self.response)
school = self.request.get('sc')
params = {}
if school:
params['sc'] = school
dest_url = '/_userconfig?' + urllib.urlencode(params)
login_url = users.create_login_url(
dest_url=dest_url,
federated_identity=federated_identity)
self.redirect(login_url)
开发者ID:SOSbeacon,项目名称:SchoolBeacon-GAE,代码行数:27,代码来源:login_openid.py
示例20: get
def get(self, resource_id, *args, **kwargs):
session_store = sessions.get_store()
session = session_store.get_session()
session['tz'] = resource_id
session_store.save_sessions(self.response)
self.response.write(resource_id)
开发者ID:SOSbeacon,项目名称:SchoolBeacon-GAE,代码行数:8,代码来源:__init__.py
注:本文中的webapp2_extras.sessions.get_store函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论