Created
May 2, 2014 19:26
-
-
Save jvanasco/aa6a844ee5f27d37f588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
session.framework = beaker | |
session.key = SessionID | |
session.type = file | |
session.data_dir = %(here)s/data/ssessions/data | |
session.lock_dir = %(here)s/data/ssessions/lock | |
session.secret = 123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyramid.config import Configurator | |
import pyramid_beaker | |
def main(global_config, **settings): | |
""" This function returns a Pyramid WSGI application. | |
""" | |
config = Configurator(settings=settings) | |
config.include('pyramid_chameleon') | |
config.add_static_view('static', 'static', cache_max_age=3600) | |
config.add_route('home', '/') | |
config.add_route('session_iterate', '/iterate') | |
config.include('pyramid_beaker') | |
config.scan() | |
return config.make_wsgi_app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyramid.view import view_config | |
from pyramid.httpexceptions import HTTPFound | |
@view_config(route_name='home', renderer='templates/mytemplate.pt') | |
def my_view(request): | |
return {'project': 'MyProject'} | |
@view_config(route_name='session_iterate', renderer='templates/mytemplate.pt') | |
def session_iterate(request): | |
print "~=" * 80 | |
if 'i' not in request.session: | |
print "new session!" | |
request.session['i'] = 0 | |
else: | |
print "existing session! increment" | |
request.session['i'] += 1 | |
if request.session['i'] >= 2 : | |
print "i <=2 -- invalidte session" | |
request.session.invalidate() | |
print "session -" | |
print request.session.id | |
print request.session | |
print "cookies -" | |
print request.cookies | |
print "response -" | |
print request.response.__dict__ | |
return {'project': 'MyProject'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment