I am trying to use a pyramid glass in a Pyramid structure and it just doesnโt work, it creates session objects, but I cannot access them using the line
@view_config(route_name='load_qli', renderer='json') def load_qli(request): request.environ['beaker.session']
It gives the following error:
KeyError KeyError: 'beaker.session'
My development.ini file is as follows
# pyramid_beaker settings session.type = file session.data_dir = %(here)s/data/sessions/data session.lock_dir = %(here)s/data/sessions/lock session.key = customerskey session.secret = customerssecret session.cookie_on_exception = true
and init.py like this
from pyramid.config import Configurator from sqlalchemy import engine_from_config from qlipe.models import DBSession from pyramid_mailer import mailer_factory_from_settings from pyramid_beaker import session_factory_from_settings def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine)
I create a session as follows
def my_view(request): session = request.session session['name'] = 'Fred Smith' session.save()
Where am I mistaken?
source share